Add a MySQL connection pool for django using gevent
Project description
Mysql Connection Pooling backend for Django < 2.0 using gevent, only supports Python 2.7 It works with gunicorn async worker via gevent. It implement an loadbalancing simple algo.
Fork from : https://github.com/shunsukeaihara/django-mysql-geventpool
This implimentation is based on django-db-geventpool(https://github.com/jneight/django-db-geventpool).
Installation
pip install django-mysql-geventpool-27
Settings
Add the ‘django_mysql_geventpool_27’ modules to the INSTALLED_APPS like this:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_mysql_geventpool-27',
# ...other installed applications...
Add MAX_CONNS to OPTIONS to set the maximun number of connections allowed to database (default=4)
DATABASES = {
'default': {
'ENGINE': 'django_mysql_geventpool_27.backends.mysql',
'NAME': 'dbname',
'USER': 'dbuser',
'PASSWORD': 'dbpassword',
'HOST': 'dbhost',
'PORT': 'dbport',
'OPTIONS': {
'MAX_CONNS': 20
}
}
}
Load balancing Galera multi master
For each connection, a random choice is operated on the HOST key of the DATABASE setting. For easy provisioning by an orchetrator like puppet/salt/ansible.., you can use this type of setting:
DATABASES = {
'default': {
'ENGINE': 'django_mysql_geventpool_27.backends.mysql',
'NAME': 'dbname',
'USER': 'dbuser',
'PASSWORD': 'dbpassword',
'HOST': 'server1,server2,serve3',
'PORT': 'dbport',
'OPTIONS': {
'MAX_CONNS': 20
}
}
}
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
Built Distribution
Hashes for django-mysql-geventpool-27-0.3.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9be17d07e79694077c75df42655c54868ce9c692e8dfd843300228469660a0b8 |
|
MD5 | e357835be45c0873a93fe2a3f2fbbbf4 |
|
BLAKE2b-256 | 410d423e0e4e79163906ec45fc3d50682ca1534b4a62027a69c456fb8f90c09d |
Hashes for django_mysql_geventpool_27-0.3.1-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55a5d6b93ffbe9836df67dfd614f97ce8d9d99b291bbaba73b4d5fe069f8e595 |
|
MD5 | 04d008bf362bf6472855f879a0ced1a2 |
|
BLAKE2b-256 | 3d24e90c5a7f49cc51100e1a9144b48187377a5941a33a253bab1d52b87be4e6 |