From litestar
Integrates Granian Rust-based ASGI server into Litestar apps for higher throughput, native HTTP/2, and lower memory. Auto-activates on litestar_granian or GranianPlugin usage.
How this skill is triggered — by the user, by Claude, or both
Slash command
/litestar:litestar-granianThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
`litestar-granian` is the first-party plugin that integrates the [Granian](https://github.com/emmett-framework/granian) Rust-based ASGI server with Litestar. Adding `GranianPlugin()` to a Litestar app makes `litestar run` launch Granian instead of uvicorn — same CLI, much higher throughput, native HTTP/2, and lower memory.
litestar-granian is the first-party plugin that integrates the Granian Rust-based ASGI server with Litestar. Adding GranianPlugin() to a Litestar app makes litestar run launch Granian instead of uvicorn — same CLI, much higher throughput, native HTTP/2, and lower memory.
For Litestar apps, always prefer litestar-granian over plain granian CLI: the plugin wires Granian into Litestar's lifespan, signal handling, CLI flags, and dev-mode reload logic.
T | None, never Optional[T]GranianPlugin MAY use from __future__ import annotations — canonical Litestar apps do.from litestar import Litestar
from litestar_granian import GranianPlugin
app = Litestar(
route_handlers=[...],
plugins=[GranianPlugin()],
)
# Same CLI as before; now backed by Granian
litestar --app app:app run --host 0.0.0.0 --port 8000
# Dev with reload
litestar --app app:app run --reload
GranianPlugin itself takes no configuration — it registers the litestar run CLI command and wires Granian's loggers into Litestar's logging config. All tuning (workers, threads, http, backpressure, SSL, structured access logs) happens on the litestar run command line or via environment variables at deploy time.
from litestar import Litestar
from litestar_granian import GranianPlugin
app = Litestar(
route_handlers=[...],
plugins=[GranianPlugin()],
)
# Production-tuned launch (8 cores, runtime threading mode, HTTP/2, bounded backpressure)
litestar --app app:app run \
--workers 8 \
--threads 2 \
--threading-mode runtime \
--http auto \
--backpressure 2000 \
--log-access \
--log-access-format json
litestar --app app:app run \
--workers 8 \
--threads 2 \
--threading-mode runtime \
--http auto \
--backpressure 2000 \
--ssl-certificate /etc/ssl/certs/app.crt \
--ssl-keyfile /etc/ssl/private/app.key
| Feature | Granian (litestar-granian) | Uvicorn |
|---|---|---|
| Core | Rust (hyper + tokio) | Python |
| HTTP/2 | Native | Requires h2 |
| Throughput | Higher | Moderate |
| Memory | Lower | Higher |
| Litestar plugin | First-party (GranianPlugin) | None — generic ASGI |
litestar run integration | Yes — drop-in replacement | Default if no plugin |
| Production default | Preferred | Fallback only |
pip install litestar-granian
Add GranianPlugin() to the Litestar(plugins=[...]) list. No other code change is required for dev — litestar run now uses Granian.
Pass tuning flags to the litestar run command for production. Match --workers to CPU cores, set --threading-mode runtime for async workloads, enable --http auto, set --backpressure to bound queue depth.
Either terminate TLS at Granian (--ssl-certificate / --ssl-keyfile) or behind a load balancer. Inside a container without an external proxy, prefer Granian-native SSL.
Run the app, confirm the startup banner mentions Granian, and load-test before going live. Tune workers / backpressure to match peak load without exhausting memory.
litestar-granian for Litestar apps, not the bare granian CLI — the plugin integrates with Litestar lifespan, dev-reload, signal handling, and CLI flags.GranianPlugin with manual granian invocations — the plugin owns the server lifecycle. Pick one.workers to CPU cores for production. Under-provisioned wastes hardware; over-provisioned bloats memory.threading_mode="runtime" for async (Litestar) workloads. workers mode is for CPU-bound sync code.http="auto" unless you have a documented reason to restrict HTTP version. Pure HTTP/2 breaks HTTP/1.1 clients.backpressure in production — without a bound, traffic spikes lead to unbounded queuing and OOM.GranianPlugin over uvicorn for all Litestar deployments — higher throughput, native HTTP/2, lower memory.async def blocked by sync I/O — Granian's event loop must stay free; sync DB/HTTP calls inside async def starve workers.Before delivering a Litestar + Granian deployment, verify:
GranianPlugin is in app.pluginsgranian app:app invocations in scripts/Dockerfilelitestar run --workers matches CPU cores (or has a documented deviation)--threading-mode runtime is set on the launch command--http auto is set on the launch command--backpressure is set for productionuvicorn in production deps (or a justification is documented)Task: Production Litestar app with GranianPlugin, tuned for an 8-core host with SSL and structured access logging.
# app.py
from litestar import Litestar, get
from litestar_granian import GranianPlugin
@get("/health")
async def health() -> dict[str, str]:
return {"status": "ok"}
app = Litestar(
route_handlers=[health],
plugins=[GranianPlugin()],
)
# Production launch — same CLI, now Granian-backed
litestar --app app:app run --host 0.0.0.0 --port 8443
For Dockerfile / process manager invocations, prefer the same Litestar CLI command rather than calling granian directly.
If you need to run Granian directly (e.g., for non-Litestar code paths), the standard granian CLI flags are the same ones the Litestar plugin forwards from litestar run:
granian app:main \
--interface asgi \
--host 0.0.0.0 \
--port 8443 \
--workers 8 \
--threads 2 \
--threading-mode runtime \
--http auto \
--backpressure 2000 \
--ssl-certfile /etc/ssl/certs/app.crt \
--ssl-keyfile /etc/ssl/private/app.key \
--log-level info \
--access-log \
--log-access-fmt json
For Litestar apps, prefer the plugin path described above.
Searches MemPalace before answering questions about past work, people, projects, or prior decisions. Returns verbatim stored content instead of guessing from model memory.
Guides Payload CMS config (payload.config.ts), collections, fields, hooks, access control, APIs. Debugs validation errors, security, relationships, queries, transactions, hook behavior.
Implements vector databases with Pinecone, Weaviate, Qdrant, Milvus, pgvector for semantic search, RAG, recommendations, and similarity systems. Optimizes embeddings, indexing, and hybrid search.
npx claudepluginhub litestar-org/litestar-skills --plugin litestar