Django Scaler
Degrade gracefully by automatically replacing heavy pages with static pages while a server is taking strain.
Installation
Install or add django-scaler to your Python path.
Add scaler to your INSTALLED_APPS setting.
Add scaler.middleware.ScalerMiddleware to the top of your MIDDLEWARE_CLASSES setting.
Add (r’^scaler/’, include(‘scaler.urls’)) to urlpatterns.
Overview
Servers may at times get overloaded due to a variety of reasons. When that happens you don’t want expensive requests to bring down your entire site. The site must redirect expensive requests to a “server busy” page while the server is under load, and then automatically remove the redirects once the load has dropped enough.
django-scaler addresses this situation in two ways. Firstly, it knows which requests to redirect by itself. Secondly, it can be instructed to redirect the N most expensive requests. It stores response time data in in-memory caches enabling it to make these decisions.
Usage
Pasted from test_settings.py:
DJANGO_SCALER = {
'server_busy_url_name': 'server-busy',
# How many response times to consider for an URL. A small value means slow
# response times are quickly acted upon, but it may be overly aggressive.
# A large value means an URL must be slow for a number of requests before
# it is acted upon. The default is 100.
'trend_size': 10,
# How much slower than average the trend must be before redirection kicks
# in. The default is 4.0.
'slow_threshold': 2.0,
# How many seconds to keep redirecting an URL before serving normally. The
# default is 60.
'redirect_for': 10,
# A function that returns how many of the slowest URLs must be redirected.
# Depending on the site, data and load on the server this may be a large
# number. This allows external processes to instruct the middleware to
# redirect. The default is 0.
'redirect_n_slowest_function': lambda: 0,
# A function that returns what percentage of the slowest URLs must be
# redirected. Depending on the site, data and load on the server this may
# approach 100. The default is 0.
'redirect_percentage_slowest_function': lambda: 0,
# A function that returns a list of regexes. URLs matching the regexes are
# redirected. Each regex is a simple string. Do not prefix with r''. The
# default is an empty list.
'redirect_regexes_function': lambda: [],
}
Changelog
0.2
Regex URL matching for explicit redirection.
Percentage slowest explicit redirection.
0.1
First release.
Release files for django-scaler 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django-scaler-0.2.tar.gz | 8.7 kB | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_scaler-0.2-py2.7.egg | Legacy Egg format | - | - | Details |
| django_scaler-0.2-py2.6.egg | Legacy Egg format | - | - | Details |
Total release size: 35.8 kB
Release files / django-scaler-0.2.tar.gz
| Download URL | django-scaler-0.2.tar.gz |
|---|---|
| Size | 8.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d4069d04176e948ffcf81267e061f2927d51dd5a0505d2e02d10b614531816d0
|
|
BLAKE2b-256 checksum How to use checksums |
c1760a1b2841ac5f5e7a252d93dca761e21c54199e5b84c27547cd54d93e3830
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / django_scaler-0.2-py2.7.egg
| Download URL | django_scaler-0.2-py2.7.egg |
|---|---|
| Size | 13.5 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
ad7c527d5d7ba33f0256a657127b1933844ebcca90508cd08ddbf97c87cd0359
|
|
BLAKE2b-256 checksum How to use checksums |
4692fae243968074c928465ea7fe72d7eecedcc19421014badfc784deb0bcd60
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / django_scaler-0.2-py2.6.egg
| Download URL | django_scaler-0.2-py2.6.egg |
|---|---|
| Size | 13.6 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
fcd8f934ebf88b00385fb00d4c19721e06a6acf7ab00f1601625f3e6484ee1c9
|
|
BLAKE2b-256 checksum How to use checksums |
0839a902c7cb23603aba1460ab26ed02490a906b7b5d7659c6aa0aa0e8e85db9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |