django-perfy
API, WebSocket and server performance monitoring for Django — with a built-in admin dashboard, PDF reports, and the option to keep all telemetry in a separate database.
django-perfy captures request latency, database query counts, WebSocket
events and host resource usage (CPU / memory / Redis / Postgres), rolls them up
into summaries, and surfaces everything through a dashboard and downloadable PDF
reports.
Links
- 📖 Documentation: https://rohith-baggam.github.io/django-perfy/
- 💻 Source code (GitHub): https://github.com/rohith-baggam/django-perfy/
- 🐛 Issues: https://github.com/rohith-baggam/django-perfy/issues
- 📦 PyPI: https://pypi.org/project/django-perfy/
Features
- API monitoring — a middleware records endpoint, method, status, response time, DB query count and DB time, with configurable sampling.
- WebSocket monitoring — a Channels consumer mixin records connect / disconnect / send / receive events and timings.
- Resource snapshots — periodic CPU, memory, Redis and Postgres metrics via Celery tasks and a self-contained background timer (works without Celery Beat).
- Rollups — minute/hour
PerformanceSummaryaggregates for fast dashboards. - Dashboard — a staff-only Jinja2 dashboard (overview, API, WebSocket, resources, DB queries, correlation, raw logs).
- PDF reports — latency, throughput, bottlenecks and resource-utilization reports, previewable in-browser, downloadable, or emailable.
- Secondary database — point all telemetry at a separate DB alias with one setting; the bundled router handles reads, writes and migrations.
Requirements
- Python 3.10+
- Django 4.2+
- Celery 5.2+, Redis, psutil (installed automatically)
jinja2+weasyprintfor the dashboard and PDF reports (thereportsextra). WeasyPrint needs system libraries (Pango, Cairo) — see its install docs.
Installation
pip install django-perfy # core
pip install "django-perfy[reports]" # + dashboard & PDF reports
Quickstart
# settings.py
INSTALLED_APPS = [
# ...
"django_perfy",
]
MIDDLEWARE = [
# ... after AuthenticationMiddleware so request.user is available ...
"django_perfy.middleware.PerformanceMiddleware",
]
python manage.py migrate
Instrument WebSocket consumers (optional):
from channels.generic.websocket import AsyncWebsocketConsumer
from django_perfy.mixins import WebSocketLoggingMixin
class ChatConsumer(WebSocketLoggingMixin, AsyncWebsocketConsumer):
...
Full install steps — extras, WeasyPrint system libraries, the dashboard's Jinja2 backend and static files, and the secondary-database migration — are in the documentation.
Configuration
All configuration lives in a single PERFORMANCE_MONITOR dict. Any key you omit
falls back to its default, and Django's system-check framework validates the
block on manage.py check.
PERFORMANCE_MONITOR = {
"ENABLED": True,
"SAMPLING_RATE": 0.1, # sample 10% of normal requests
"SLOW_REQUEST_THRESHOLD_MS": 500, # always capture requests slower than this
"EXCLUDED_PATHS": ["/health/", "/metrics/", "/favicon.ico"],
"RETENTION_DAYS_RAW": 30,
"RETENTION_DAYS_RESOURCES": 90,
"QUEUE_NAME": "performance_logs",
"USER_ID_SALT": "change-me", # salts hashed user ids
"SERVICES": [],
# Off by default: headers/bodies routinely carry session cookies/auth
# tokens/PII. See the settings reference for the full redaction options.
"CAPTURE_HEADERS": False,
"REDACTED_HEADERS": ["authorization", "cookie", "set-cookie", "x-api-key"],
"CAPTURE_BODY": False,
"REDACTED_BODY_FIELDS": ["password", "token", "secret", "card_number"],
# Store telemetry in the default DB, or point at a secondary alias:
"DATABASE": "default",
}
CAPTURE_HEADERSandCAPTURE_BODYdefault toFalsebecause headers and bodies routinely carry session cookies, auth tokens and other PII. Leave both off until you've reviewedREDACTED_HEADERSandREDACTED_BODY_FIELDS— turning them on isn't a casual flip.
Every key, its type, default and description is in the settings reference, and the parts that need more explanation are covered under Configuration.
Documentation
| Topic | Link |
|---|---|
| Why django-perfy (vs Prometheus/Grafana) | https://rohith-baggam.github.io/django-perfy/why-django-perfy/ |
| Getting started | https://rohith-baggam.github.io/django-perfy/getting-started/ |
| Configuration | https://rohith-baggam.github.io/django-perfy/configuration/ |
| Dashboard & reports | https://rohith-baggam.github.io/django-perfy/features/dashboard-and-reports/ |
| Secondary database | https://rohith-baggam.github.io/django-perfy/guides/secondary-database/ |
| Emailing reports | https://rohith-baggam.github.io/django-perfy/guides/email/ |
| Celery setup | https://rohith-baggam.github.io/django-perfy/guides/celery-setup/ |
| Management commands | https://rohith-baggam.github.io/django-perfy/reference/management-commands/ |
| Intro, demo & installation videos | https://rohith-baggam.github.io/django-perfy/background/ |
Development
python -m venv .venv && . .venv/bin/activate
pip install -e ".[dev,reports]"
pytest
pre-commit install
License
MIT — see LICENSE.
Metadata
Release files for django-perfy 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django_perfy-0.1.0.tar.gz | 141.4 kB | Without provenance | Details for django_perfy-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_perfy-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for django_perfy-0.1.0-py3-none-any.whl |
Total release size: 261.7 kB
Release files / django_perfy-0.1.0.tar.gz
| Download URL | django_perfy-0.1.0.tar.gz |
|---|---|
| Size | 141.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
71ca8e698817e992e780610dc5107ed4ea1546fed81e2f78b6ff1a677394e5d4
|
|
BLAKE2b-256 checksum How to use checksums |
6dc9fe705538f4ad61de923b672dcabf68cf4f2344ba8173e7be6aa05e87ca27
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / django_perfy-0.1.0-py3-none-any.whl
| Download URL | django_perfy-0.1.0-py3-none-any.whl |
|---|---|
| Size | 120.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f19ffad91714123fa8858fbb6e56019ce594b37731ac6c75a1c13b87a7980b8b
|
|
BLAKE2b-256 checksum How to use checksums |
245a353f0339dcc786f34ad2ebad662a6371e493f7f9e6b8d524edc97ca90d05
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for django-perfy 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.