litestar-granian

Configures and tunes the Granian Rust ASGI server for Litestar applications via GranianPlugin.

Updated Aug 17, 2026
One-click install
npx skills add https://github.com/renjianguo666/litecms --skill litestar-granian-renjianguo666
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: litestar-granian
Source: https://github.com/renjianguo666/litecms/tree/main/.agents/skills/litestar-granian
Command: npx skills add https://github.com/renjianguo666/litecms --skill litestar-granian-renjianguo666

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires litestar-granian.

What problem does it solve? Serving Litestar applications in production requires choosing and tuning an ASGI server, and the default uvicorn setup lacks native HTTP/2, higher throughput, and lower memory usage. This Skill guides the integration of the Granian Rust-based ASGI server into Litestar apps through the first-party GranianPlugin, covering worker tuning, threading modes, backpressure, SSL, and structured access logging. ## Core Features & Use Cases - Zero-config plugin integration: Add GranianPlugin to the Litestar plugins list so the standard litestar run CLI launches Granian instead of uvicorn with no other code changes. - Production tuning guidance: Configure workers, threads, threading-mode runtime, HTTP auto-negotiation, backpressure bounds, and JSON access logs through litestar run flags. - SSL and deployment patterns: Terminate TLS directly with Granian ssl-certificate and ssl-keyfile flags or document a reverse proxy setup. - Use Case: Deploying an 8-core production Litestar service with HTTP/2, bounded backpressure, and structured access logs using a single litestar run command. ## Quick Start Add GranianPlugin to my Litestar app's plugins list and show me the production litestar run command tuned for an 8-core host with SSL enabled.

Frequently Asked Questions about litestar-granian

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I serve a Litestar app with Granian instead of uvicorn?

Install litestar-granian and add GranianPlugin() to the Litestar app's plugins list. The standard litestar run command then launches Granian automatically, with no other code changes required.

Granian vs uvicorn for Litestar production deployments?

Granian is a Rust-based server offering higher throughput, native HTTP/2, and lower memory usage, with a first-party Litestar plugin. Uvicorn remains the default fallback when no plugin is installed but lacks these advantages.

How do I tune Granian workers and threads for production?

Pass flags to litestar run: match --workers to CPU cores, set --threads 2 with --threading-mode runtime for async workloads, enable --http auto, and set --backpressure to bound queue depth against traffic spikes.

Does Granian support SSL and HTTP/2 for Litestar apps?

Yes. Pass --ssl-certificate and --ssl-keyfile to litestar run for native TLS termination, and use --http auto to negotiate HTTP/2 while keeping HTTP/1.1 clients working.

Can I run the granian CLI directly alongside GranianPlugin?

No. Never mix GranianPlugin with manual granian invocations because the plugin owns the server lifecycle, including lifespan, signal handling, and dev reload. Pick one approach per deployment.

Why do my Litestar handlers perform poorly under Granian?

Sync I/O inside async handlers blocks Granian's event loop and starves workers. Keep all database and HTTP calls async so the runtime threading mode can schedule work efficiently.