{ "info": { "author": "Ben Timby", "author_email": "btimby@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Operating System :: OS Independent", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": ".. image:: https://travis-ci.org/btimby/django-proxysql.png\n :target: https://travis-ci.org/btimby/django-proxysql\n\n.. image:: https://coveralls.io/repos/github/btimby/django-proxysql/badge.svg?branch=master\n :target: https://coveralls.io/github/btimby/django-proxysql?branch=master\n\n.. image:: https://badge.fury.io/py/django-proxysql.svg\n :target: https://badge.fury.io/py/django-proxysql\n\ndjango-proxysql\n---------------\n\nWhat?\n=====\n\nA software load balancer for your Django database. This project provides a\nDjango database engine that manages multiple peer database connections and\ndistributes queries to each equally. It also notes if a peer fails and stops\nsending queries to that peer until it recovers.\n\nThis project was developed for MySQL, Galera and ProxySQL. However it could be\nused with any Django compatible database engine. Most likely the connection\nerror detection would need to be adapted (as ``MySQLdb.Error`` is used to\ndetect failure).\n\n``django-proxysql`` can be used without ProxySQL (for instance, your peers\ncould be Galera cluster nodes), or with a different load balancer such as\nMaxScale. You can also combine this with multidb, where your Django router\nroutes between multiple pools of database peers.\n\nWhy?\n====\n\nDjango multidb support is implemented at a high level. Thus it is not aware of\nconnection failures. It will continue routing queries to a down host causing\nerrors.\n\nSome suggest adding a liveness check within the multidb router, but this adds\nunecessary overhead. ``django-proxysql`` also routes queries, but at the\ndatabase engine level which enables it to identify connection failures and\nroute queries accordingly.\n\n``django-proxysql`` assumes you are using a pool of peer MySQL, ProxySQL or\nMaxScale servers that are all exactly equivalent. It does not intelligently\nroute queries, that is left to the downstream peers.\n\nHow?\n====\n\nConfigure your MySQL peers as additional databases in Django settings. Then\nconfigure your ``default`` django database to use this engine and specify the\npeers. You can also specify the optional ``CHECK_INTERVAL`` which controls how\noften a downed peer is rechecked (30s default).\n\n\n.. code:: python\n\n DATABASES = {\n 'default': {\n 'ENGINE': 'django_proxysql.backends.proxysql',\n 'PEERS': ['peer0', 'peer1'],\n 'CHECK_INTERVAL': 30,\n },\n 'peer0': {\n 'ENGINE': 'django.db.backends.mysql',\n 'NAME': 'db_name',\n 'USER': 'user',\n 'PASSWORD': 'password',\n 'HOST': 'peer0',\n 'PORT': 6033,\n },\n 'peer1': {\n 'ENGINE': 'django.db.backends.mysql',\n 'NAME': 'db_name',\n 'USER': 'user',\n 'PASSWORD': 'password',\n 'HOST': 'peer1',\n 'PORT': 6033,\n },\n }\n\nNow when you use the default database in Django, connections will be randomly\ndistributed to the peers.\n\nIf you don't need a dedicated load balancer such as ProxySQL or MaxScale, you\ncan simply configure your Galera cluster nodes as your peers.\n\n.. code:: python\n\n DATABASES = {\n 'default': {\n 'ENGINE': 'django_proxysql.backends.proxysql',\n 'PEERS': ['galera0', 'galera1'],\n },\n 'peer0': {\n 'ENGINE': 'django.db.backends.mysql',\n 'NAME': 'db_name',\n 'USER': 'user',\n 'PASSWORD': 'password',\n 'HOST': 'galera0',\n 'PORT': 6033,\n },\n 'peer1': {\n 'ENGINE': 'django.db.backends.mysql',\n 'NAME': 'db_name',\n 'USER': 'user',\n 'PASSWORD': 'password',\n 'HOST': 'galera1',\n 'PORT': 6033,\n },\n }\n\n\nYou can configure more than one ``django-proxysql`` backend and then use Django\nmultidb to route between those.\n\n.. code:: python\n\n DATABASES = {\n 'default': {\n 'ENGINE': 'django_proxysql.backends.proxysql',\n 'PEERS': ['peer0', 'peer1'],\n },\n 'users': {\n 'ENGINE': 'django_proxysql.backends.proxysql',\n 'PEERS': ['peer2', 'peer3'],\n },\n 'peer0': {\n 'ENGINE': 'django.db.backends.mysql',\n 'NAME': 'db_name',\n 'USER': 'user',\n 'PASSWORD': 'password',\n 'HOST': 'peer0',\n 'PORT': 6033,\n },\n 'peer1': {\n 'ENGINE': 'django.db.backends.mysql',\n 'NAME': 'db_name',\n 'USER': 'user',\n 'PASSWORD': 'password',\n 'HOST': 'peer1',\n 'PORT': 6033,\n },\n 'peer2': {\n 'ENGINE': 'django.db.backends.mysql',\n 'NAME': 'db_name',\n 'USER': 'user',\n 'PASSWORD': 'password',\n 'HOST': 'peer2',\n 'PORT': 6033,\n },\n 'peer3': {\n 'ENGINE': 'django.db.backends.mysql',\n 'NAME': 'db_name',\n 'USER': 'user',\n 'PASSWORD': 'password',\n 'HOST': 'peer3',\n 'PORT': 6033,\n },\n }\n\n\nAnything Else?\n==============\n\nBecause only connection errors are handled by the engine, other errors like\ndropped connections will cause failures in your application. Therefore if you\nare performing a rolling upgrade, you must gracefully drain each peer. For\nexample, with ProxySQL you can do this by issuing the ``PROXYSQL PAUSE``\ncommand within the admin interface (port 6032). This causes ProxySQL to stop\naccepting new connections, which ``django-proxysql`` will detect and handle\nwithout a single error.\n\nAlso note that when migrations are applied, Django performs a check of ALL\nCONFIGURED DATABASES. This bears repeating. All database peers must be online\nin order to perform database migrations.", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/btimby/django-proxysql/", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "django-proxysql", "package_url": "https://pypi.org/project/django-proxysql/", "platform": "", "project_url": "https://pypi.org/project/django-proxysql/", "project_urls": { "Homepage": "http://github.com/btimby/django-proxysql/" }, "release_url": "https://pypi.org/project/django-proxysql/0.3/", "requires_dist": null, "requires_python": "", "summary": "Integration between Django and Kubernetes.", "version": "0.3" }, "last_serial": 5806597, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "7733a20fadf8e5c338a861ce1d36eb49", "sha256": "d5cb3a88fcce49060c4649af74a1cd6581521eb80405dbd914d9d3259c09da81" }, "downloads": -1, "filename": "django-proxysql-0.1.tar.gz", "has_sig": false, "md5_digest": "7733a20fadf8e5c338a861ce1d36eb49", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3107, "upload_time": "2019-09-10T00:22:47", "url": "https://files.pythonhosted.org/packages/09/45/f7a09952d7fa54f45b06cb246347176b0bd71fe4ee8ce8d68ac28f4b6ba5/django-proxysql-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "566c505de5d000221fb287da4dcc8204", "sha256": "3b47bf482adfd45a823c9c0f1c9a9d5a598131fc82c48132c793f7c3456dc32b" }, "downloads": -1, "filename": "django-proxysql-0.2.tar.gz", "has_sig": false, "md5_digest": "566c505de5d000221fb287da4dcc8204", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3602, "upload_time": "2019-09-10T02:34:17", "url": "https://files.pythonhosted.org/packages/f4/e1/5e3d2b2fdd23b1d94acd72262a01dcb16017cfd5145eb6f0bbbf15a3ef1a/django-proxysql-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "8979088755bdf157b42f3bfd8f52649f", "sha256": "43d86b0a0241635c75c2bef9c4e22d1c310acb1126981c80e33de8a8b430d73d" }, "downloads": -1, "filename": "django-proxysql-0.3.tar.gz", "has_sig": false, "md5_digest": "8979088755bdf157b42f3bfd8f52649f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3949, "upload_time": "2019-09-10T02:46:08", "url": "https://files.pythonhosted.org/packages/72/2a/ef712a182fb5133c5cdc815443862add834b67c6bf9c6c42c231c7f529d9/django-proxysql-0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "8979088755bdf157b42f3bfd8f52649f", "sha256": "43d86b0a0241635c75c2bef9c4e22d1c310acb1126981c80e33de8a8b430d73d" }, "downloads": -1, "filename": "django-proxysql-0.3.tar.gz", "has_sig": false, "md5_digest": "8979088755bdf157b42f3bfd8f52649f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3949, "upload_time": "2019-09-10T02:46:08", "url": "https://files.pythonhosted.org/packages/72/2a/ef712a182fb5133c5cdc815443862add834b67c6bf9c6c42c231c7f529d9/django-proxysql-0.3.tar.gz" } ] }