Integration between Django and Kubernetes.
Project description
django-proxysql
What?
A software load balancer for your Django database.
Why?
Often times you are using ProxySQL in conjunction with a highly available MySQL server cluster. It would not make sense to use just a single ProxySQL instance. You may wish to have an active / active ProxySQL cluster in this case. However normal Django multidb does not smoothly handle failure of one of the ProxySQL nodes. This engine does. When one of your configured ProxySQL servers refuses a connection, it is marked down for a period of time before being retried. Meanwhile all remaining ProxySQL servers are used without interruption.
How?
Configure your ProxySQL servers as additional databases django databases. Then configure your default django database to use this engine and specify the peers.
DATABASES = {
'default': {
'ENGINE': 'backends.proxysql',
'PEERS': ['peer0', 'peer1'],
'CHECK_INTERVAL': 30,
},
'peer0': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'db_name',
'USER': 'user',
'PASSWORD': 'password',
'HOST': 'peer0',
'PORT': 6033,
},
'peer1': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'db_name',
'USER': 'user',
'PASSWORD': 'password',
'HOST': 'peer1',
'PORT': 6033,
},
}
Now when you use your database in Django, connections will be randomly distributed to the peers. Failure of a peer is transparent to Django. Failed peers will recover after the configured CHECK_INTERVAL.
Anything Else?
Yes, to perform maintenance on a ProxySQL instance, just connect to it’s admin port, 6032 and issue a PROXYSQL PAUSE command. This will start refusing new clients, but allow running queries to complete. django-proxysql will detect the “failure” of the node and stop attempting to connect to it. Once all active connections are drained, you can stop ProxySQL, perform maintenance then restore the service. You can repeat this for each instance of ProxySQL without any downtime.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file django-proxysql-0.1.tar.gz
.
File metadata
- Download URL: django-proxysql-0.1.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5cb3a88fcce49060c4649af74a1cd6581521eb80405dbd914d9d3259c09da81 |
|
MD5 | 7733a20fadf8e5c338a861ce1d36eb49 |
|
BLAKE2b-256 | 0945f7a09952d7fa54f45b06cb246347176b0bd71fe4ee8ce8d68ac28f4b6ba5 |