Skip to content

Redline

See inside every request

A self-hosted request profiler, backend analyzer and load tester for Django, FastAPI, Flask and Litestar. Find the slow query, get the fix as a diff, then push load at it and see what breaks first.

Get started View on GitHub

The N+1 issue of the Django demo shop in Redline: 30 queries from one line, with a prefetch_related diff The N+1 issue of the Django demo shop in Redline, dark theme

Built for AI agents

Redline ships an MCP server, fix briefs, a verify-a-fix command, LLM-call observability and machine-readable docs (llms.txt). See Working with AI agents.

Beta: 0.5 development release

This checkout contains the next release's features; PyPI can contain an earlier version. See Getting started for published and local workspace installs. APIs and settings can change. Start with development/staging, and use the deployment-specific production validation gate before recording real traffic.

Install in a minute

pip install \
  "django-redline @ git+https://github.com/Pythondeveloper6/redline#subdirectory=packages/django-redline" \
  "redline-core @ git+https://github.com/Pythondeveloper6/redline#subdirectory=packages/redline-core"
# settings.py
INSTALLED_APPS = [..., "django_redline"]

MIDDLEWARE = [
    "django.middleware.security.SecurityMiddleware",
    "django_redline.middleware.RedlineMiddleware",   # as high as possible
    ...,
]
# urls.py
from django.urls import include, path

urlpatterns = [
    ...,
    path("redline/", include("django_redline.urls")),
]

Run your app, make a few requests, and open /redline/ as a superuser.

pip install \
  "fastapi-redline @ git+https://github.com/Pythondeveloper6/redline#subdirectory=packages/fastapi-redline" \
  "redline-core @ git+https://github.com/Pythondeveloper6/redline#subdirectory=packages/redline-core"
from fastapi import FastAPI
from sqlalchemy.ext.asyncio import create_async_engine
from fastapi_redline import install

app = FastAPI()
engine = create_async_engine("sqlite+aiosqlite:///app.db")

# access="local": localhost only (unset, Redline answers 404 outside debug mode)
install(app, engine=engine, settings={"access": "local"})  # UI at http://localhost:8000/_redline/
pip install \
  "flask-redline @ git+https://github.com/Pythondeveloper6/redline#subdirectory=packages/flask-redline" \
  "redline-core @ git+https://github.com/Pythondeveloper6/redline#subdirectory=packages/redline-core"
from flask import Flask
from sqlalchemy import create_engine
from flask_redline import Redline

app = Flask(__name__)
engine = create_engine("sqlite:///app.db")

# access="local": localhost only (unset, Redline answers 404 outside debug mode)
Redline(app, engine=engine, settings={"access": "local"})  # UI at http://localhost:5000/_redline/

With Flask-SQLAlchemy, omit the engine.

pip install \
  "litestar-redline @ git+https://github.com/Pythondeveloper6/redline#subdirectory=packages/litestar-redline" \
  "redline-core @ git+https://github.com/Pythondeveloper6/redline#subdirectory=packages/redline-core"
from litestar import Litestar
from sqlalchemy.ext.asyncio import create_async_engine
from litestar_redline import RedlinePlugin

engine = create_async_engine("sqlite+aiosqlite:///app.db")

app = Litestar(
    route_handlers=[...],
    # access="local": localhost only (unset, Redline answers 404 outside debug mode)
    plugins=[RedlinePlugin(engine=engine, settings={"access": "local"})],  # UI at http://localhost:8000/_redline/
)

That is the whole setup. Traces go to their own SQLite file (.redline/redline.db), never to your application database.

The source-install commands name adapter and core together to keep their exact-version pin aligned. Published prereleases can instead be installed with pip install --pre and the framework adapter name. For unreleased features, use the matching local workspace. Details.

What you get

  • Profile every request


    A waterfall of spans for middleware, view, SQL, cache, templates, serializers, transactions and outbound HTTP, with logs, exception locals and opt-in flamegraphs.

    How it works

  • Analyze, with the fix attached


    N+1 queries mapped back to your source line and written as a diff (prefetch_related, selectinload...). One-click EXPLAIN, an index advisor, event-loop blocking, long transactions, huge results, slow serializers and external calls.

    N+1 · Detectors

  • Load test and find the knee


    redline load drives your app at a real arrival rate, corrects for coordinated omission, finds the knee, and shows which query went from 3 ms to 410 ms at which step.

    Load testing

  • Prove a refactor is safe


    redline check replays a set of read-only requests against the old code and the new, and reports what changed in the responses, which endpoints got faster or slower (with a significance test), and which queries appeared or went away. Exit code and PR comment included.

    Refactor check

  • Compare releases


    Hourly rollups kept for 90 days, stamped with your release. Compare two releases and get a verdict per endpoint, plus the issues that are new or resolved.

    History

  • Five integrations


    Django (with Ninja and DRF), FastAPI, Flask, Litestar and a framework-free core, plus requests, httpx, Redis, asyncpg, psycopg, Marshmallow, Strawberry and Graphene hooks.

    Integrations · Extending

  • Redacted and locked down


    Secrets are masked before anything is stored. One access policy for every framework, read-only mode and a production preset. State lives in contextvars, so async is attributed correctly.

    Security · Access control

Five integrations, one tool

Framework Package Read
Django (including Ninja and DRF) django-redline Django, Django Ninja
FastAPI + SQLAlchemy fastapi-redline FastAPI
Flask (and Flask-SQLAlchemy) flask-redline Flask
Litestar + SQLAlchemy litestar-redline Litestar
Anything else redline-core Extending

A closer look

Requests list Requests list

Request timeline Request timeline

Deduplicated issues Deduplicated issues

EXPLAIN drawer EXPLAIN drawer

Flamegraph Flamegraph

Endpoint aggregates Endpoint aggregates

Redacted headers and body Redacted headers and body

SQLAlchemy N+1 with a selectinload diff SQLAlchemy N+1 with a selectinload diff

Why another profiler

Request profilers split into two camps. In-page toolbars show one request, in development, and forget it. Hosted APMs see production but not your source lines, and they are another vendor. The self-hosted middle ground is thin: django-silk is Django-only and has no async story, and nothing comparable exists for FastAPI, Flask or Litestar.

Redline is built for that middle: a persistent record of recent requests, in your own process and your own disk, that knows enough about your ORM to say which line to change, and can push load at the same app to show where it bends. It is not trying to replace a hosted APM for fleet-wide production monitoring (see the comparison and the FAQ).

How it compares

Redline django-silk django-debug-toolbar Kolo Sentry / Logfire Locust / k6
Django Yes Yes Yes Yes Yes n/a (black box)
FastAPI, Flask, Litestar / SQLAlchemy Yes No No Not its focus Yes n/a
Async-correct recording Yes (contextvars) No async support Partial (async views supported in recent versions) n/a Yes n/a
Names the call that blocks the event loop Yes No No No Partial No
Persists traces across requests Yes, own SQLite file Yes, in your app DB History panel only Local trace store Hosted Results only
N+1 detection Yes, grouped and deduplicated Manual (count queries) Query counts and "similar" markers Shows repeated queries Yes (performance issues) No
Fix suggestion as a diff Yes (Django and SQLAlchemy) No No No No (generic advice) No
EXPLAIN Yes, safe by default No Yes (per query, in page) No No No
Plan analysis + index advice Yes, per query and workload-wide No No No No No
Flamegraphs Opt-in, per request cProfile call tree Optional profiling panel Call traces Profiling products No
Secrets redacted on write Yes, by default Stores bodies and headers as captured n/a (not persisted) Local only Scrubbing is configurable n/a
Before/after across releases Yes (90 days of rollups) No No No Yes (releases) Results only
Runs in production Possible, with care (preset) Heavy; not advised No No Built for it Against staging
Distributed tracing across services No No No No Yes n/a
Load testing Yes, open model, shows the culprit query per step No No No No Yes, far more mature and flexible
Hosted, zero ops No No No Editor extension Yes Yes

Read this table with its omissions in mind. If you need cross-service traces, alerting, or fleet dashboards, use Sentry or Logfire (Redline can sit beside them). If you need a mature, scriptable, large-scale distributed load generator, use Locust or k6: Redline's load tester is scenario-file driven (HTTP, held streams and WebSockets, optionally spread over a few generator hosts), and its value is the correlation with what happened inside the server. Where this table says "No" for another tool it means "not as a built-in feature", and tools change: check theirs.

Requirements

Python Framework Other
redline-core 3.10+ none no runtime dependencies
django-redline 3.12+ Django 5.2, 6.0 or 6.1
fastapi-redline 3.10+ FastAPI 0.110+ SQLAlchemy 2.x
flask-redline 3.10+ Flask 3.0+ SQLAlchemy 2.x
litestar-redline 3.10+ Litestar 2.12+ SQLAlchemy 2.x

Flamegraphs need the profile extra (pyinstrument); the load tester needs the load extra (httpx). There is no Node.js requirement: the web UI ships prebuilt inside redline-core.

All pages

Every page, with what is in it

Get started and guide

Page What is in it
Getting started Install, mount, first look, for all four frameworks
How it works Recording, contextvars, sampling, storage and the overhead model
The UI A tour of every page, filter, shortcut and action
Server-Timing and the badge The header and the floating pill
N+1 detection Detection rules, thresholds, fix suggestions with real diffs
EXPLAIN Vendors, safety, findings, index suggestions
Flamegraphs Opt-in profiling, modes, speedscope export
Custom spans Timing your own code with redline_core.span
Issues and endpoints Aggregates, percentiles, issue deduplication

Analysis

Page What is in it
Detectors overview Every issue kind, threshold and span kind
Blocking in async The event-loop lag monitor
Transactions and locks Long transactions, HTTP in a transaction, pool waits
Large and unbounded results Rows, missing LIMIT, len(qs) vs .exists()
Slow serializers DRF, Pydantic and Marshmallow
External calls Slow, duplicated and retried outbound HTTP
Cache efficiency Hit rate, unread writes, stampedes
Logs and exceptions Logs per request, locals in exceptions
Database SQL search, index advisor, unused indexes
Static N+1 scan Find N+1s in templates and serializers without running code
GraphQL Resolver spans and N+1 over GraphQL

Load and history

Page What is in it
Load testing Open model, the knee, scenarios, CLI, CI, bottlenecks
History and releases Rollups, release compare, regressions, retention

Integrations

Page What is in it
Django, Django Ninja Middleware, URLs, settings, permission, CSRF, hooks, checks, commands, DRF
FastAPI install(), engines, auth dependencies, CSRF, lifespan
Flask Redline(app), Flask-SQLAlchemy, factories, flask redline
Litestar RedlinePlugin, engines, guards
Integrations requests, httpx, Redis, asyncpg, psycopg, Marshmallow
Extending FixSuggester and the Store protocol

Operations and reference

Page What is in it
Configuration Presets, redline.toml, environment variables, precedence
Access control Policies and recipes for VPNs, proxies, Kubernetes
Production The production preset, sampling, retention, what not to do
Security Redaction, what is stored, exposure, load-from-UI safety
Storage The SQLite store, schema v2, the writer thread, retention
Performance and overhead The cost model and the measured overhead
Settings reference Every setting, its type, default and effect
The HTTP API Every endpoint with examples
Command line redline and the framework commands
Roadmap What shipped in 0.2 and what comes next
FAQ How finished it is, how it differs from other tools

Licence

Redline is open source under the MIT licence, copyright © 2026 Mahmoud Ahmed.