Skip to main content

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

Recent versions of Python and Django. See pyproject.toml for exact versions.

Installation

Install from git

pip install git+<git address>#egg=django-request-queue-timeout

Install from PyPI

pip install django-request-queue-timeout

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-request-queue-timeout-1.0.3.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file django-request-queue-timeout-1.0.3.tar.gz.

File metadata

File hashes

Hashes for django-request-queue-timeout-1.0.3.tar.gz
Algorithm Hash digest
SHA256 a9284d1c2f08ac4ca24c0329e843b653cd3b874122e80a8f5d40fd173a4e903e
MD5 92b9aa04ecf20487da4d7bec1f6c2382
BLAKE2b-256 5ff1b3b508478202c35cd0644d40054d49b83af5d1b429fd406104bea0d96195

See more details on using hashes here.

File details

Details for the file django_request_queue_timeout-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for django_request_queue_timeout-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5b304e91a14f2c5e8fae1a37f81ec41042b67610b5b235047a2ebb786983523f
MD5 685ef463b310f66324d4c59d8e87d4d0
BLAKE2b-256 bc1ce579a8677e1d19f995cf2cb841df0f1307e27b1fc6698daa4d8ee75a58e5

See more details on using hashes here.

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