Skip to main content

Add a MySQL connection pool for django using gevent

Project description

https://circleci.com/gh/laurentL/django-mysql-geventpool/tree/master.svg?style=svg

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

django-mysql-geventpool-27-0.3.2.tar.gz (4.5 kB view details)

Uploaded Source

File details

Details for the file django-mysql-geventpool-27-0.3.2.tar.gz.

File metadata

  • Download URL: django-mysql-geventpool-27-0.3.2.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.3

File hashes

Hashes for django-mysql-geventpool-27-0.3.2.tar.gz
Algorithm Hash digest
SHA256 1c96e5ea3465330ba9cd942d281359a07456e74aa8524f5ecf8cadf0ab06dd23
MD5 d4aef27746f2e932529b1645f3fdf8c6
BLAKE2b-256 a652f68c9913b809f3b05e325423c30f648a067d437fc1e642dd29f0cffce587

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page