Django middleware class to quickly dispatch any requests that wait too long in a queue before being processed
Project description
Django-Request-Queue-Timeout
This package provides a Django middleware class to quickly dispatch any requests that wait too long in a queue before being processed.
This is useful in environments like Heroku, where traffic spikes can result in requests remaining in the queue well beyond the 30 second limit the Heroku router enforces before giving up on the request. With this middleware in place, applications recover much more quickly by not wasting time processing requests for which clients have already received a server error response.
Requirements
- Python >= 3.6
- Django >= 2.2
Installation
Install from git
pip install git+<git address>#egg=django-request-queue-timeout
Install from PyPI
pip install django-request-queue-timeout # Not yet published to PyPI
Add to MIDDLEWARE
list in settings file as the first item:
MIDDLEWARE = (
'rqto.middleware.RequestQueueTimeoutMiddleware'
...
)
Configuration
When installed, the middleware checks each incoming request for a X-REQUEST-START
header value indicating when the request started (in milliseconds since the unix epoch). If the request has queued too long before being processed a 503 Service Unavailable
response is generated.
The timeout is 30 seconds by default, but can be configured to a different value by providing a Django setting:
REQUEST_QUEUE_TIMEOUT_IN_SECONDS = 60 # configure a 60 second request queue timeout
See Also
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
Built Distribution
File details
Details for the file django-request-queue-timeout-1.0.2.tar.gz
.
File metadata
- Download URL: django-request-queue-timeout-1.0.2.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | af9840e71baee46b7821454583bd307e8973ee5c33c8a26760c6d858dcc66543 |
|
MD5 | 27c72c69bae663b3cf618a1695b6ea79 |
|
BLAKE2b-256 | 4d6bc5a10f3e09baf8bf55b63721b81f23e5bb60efcf4802ed1a4f4d65a49052 |
File details
Details for the file django_request_queue_timeout-1.0.2-py3-none-any.whl
.
File metadata
- Download URL: django_request_queue_timeout-1.0.2-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4fb2b8177dca33e8d8d977ffc80f70e129b3795919f34a13616bfcd83043b492 |
|
MD5 | d89a4abb3a32d349a66e97fdaf554854 |
|
BLAKE2b-256 | a8c1efeaa3c1241d90d5fe76da6f3c3f752bcf990fa7d7652cd0fa9257c3c5cb |