Python / Uvicorn Fundamentals Interview Questions
What are httptools and h11, and when would you choose each?
Uvicorn supports two HTTP parser implementations, selectable via the --http flag. The default auto setting picks httptools if installed (via the standard extras) or falls back to h11.
| Feature | h11 | httptools |
|---|---|---|
| Implementation | Pure Python (h11 library) | Cython bindings to llhttp (C parser) |
| Performance | Moderate | ~20-30% faster HTTP parsing |
| PyPy support | Yes | No - requires CPython |
| Standards compliance | Very strict - helpful for debugging | Production-grade |
| Error messages | More descriptive | Minimal |
| Install | Always available (default) | pip install httptools (included in uvicorn[standard]) |
# Auto - picks httptools if available (recommended for production) uvicorn main:app --http auto # Force httptools (fast, production) uvicorn main:app --http httptools # Force h11 (pure Python, debugging, PyPy) uvicorn main:app --http h11 # h11 also has a configurable buffer limit: # --limit-max-requests sets max request buffer size (h11 only) uvicorn main:app --http h11 --limit-max-requests 1000
Production recommendation: use httptools for its speed advantage. Use h11 when running on PyPy, in strict compliance testing environments, or when debugging malformed HTTP requests (h11's error messages are more descriptive).
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
