Package enabling to load balance requests to databases in django projects
Project description
DjangoLoadBalancer
Package enabling to load balance requests to databases in django projects.
Instalation
pip install djangoloadbalancer
How to use
- Rather than extending models.Model, your models must extend LoadBalancerModel, example:
from django.db import models
from DjangoLoadBalancer.django_load_balancer import load_balancer_model
class Destination(load_balancer_model):
name = models.CharField(max_length=100)
desc = models.CharField(max_length=100)
- Specify load balancer's settings in project's settings.py file, examples:
LOAD_BALANCER={
'CUD_ALGORITHM': 'MULTITHREADING',
'R_ALGORITHM': {
'NAME':'ROUND_ROBIN',
},
'DATABASES': ['default','DB1','DB2'],
'WAIT_TIME': 10,
}
LOAD_BALANCER={
'CUD_ALGORITHM': 'MULTITHREADING',
'R_ALGORITHM': {
'NAME':'INTERVAL_TIME',
'INTERVAL' : 5
},
'DATABASES': ['default','DB1','DB2'],
'WAIT_TIME': 10,
}
- R_ALGORITHM - algorithm that will determine to which database will be the next READ query sent
- ROUND_ROBIN - next database for READ query is just the next in list
- INTERVAL_TIME - regularly sends queries to databases to determine their response time. This response time is later used to choose database for READ query - the database with the smallest response time will be chosen. Queries to determine response time are send every INTERVAL seconds.
- DATABASES - names of databases from settings.py's DATABASES that will be used for loadbalancing
- WAIT_TIME - amount of time that load balancer will wait to check if the database, that went down, is up
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
djangoloadbalancer-0.0.46.tar.gz
(10.7 kB
view hashes)
Built Distribution
Close
Hashes for djangoloadbalancer-0.0.46.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94d07b7848db51e5e738c442530a3b26267a1f9ad9fceecefa110f30f69b6a4d |
|
MD5 | b37f23f0e48670d2a52f14373f8afadb |
|
BLAKE2b-256 | fb52ac0000f12a93e4f385b0096331f25d23f647353774692a8a6a7be58d8f2f |
Close
Hashes for djangoloadbalancer-0.0.46-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4ae84356f716e4dd505a4bb61936e808924a475d8ec62c64c5080c636c05d1a |
|
MD5 | 2103a61418058404a356a03e38db48df |
|
BLAKE2b-256 | 0e613e213f19871bc9cd66d6509670678b114cc7ce6deda67afad3b2e24e3443 |