Skip to main content

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

  1. Rather than extending models.Model, your models must extend LoadBalancerModel, example:
from django.db import models
from DjangoLoadBalancer.DjangoLoadBalancer import LoadBalancerModel

class Destination(LoadBalancerModel):
    name = models.CharField(max_length=100)
    desc = models.CharField(max_length=100)
  1. 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


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.31.tar.gz (7.1 kB view hashes)

Uploaded Source

Built Distribution

djangoloadbalancer-0.0.31-py3-none-any.whl (12.8 kB view hashes)

Uploaded Python 3

Supported by

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