The no-magic web API and microservices framework for Python developers, with a focus on reliability and performance at scale. - falconry/falcon
Robyn and Socketify.py <3
Last week at work, I rewrote an API to use FastAPI and as much async Python as possible. Then I benchmarked the old and new versions of the API to see which was truly fastest. The summary? FastAPI and async Python made my API much faster. Check the rest of this article for the longer story, including how the rewrite went, bugs I ran into, and benchmarks. About FastAPI FastAPI is an async Python web framework. It was the #3 web framework in the 2020 Python Developers Survey by Jetbrains. The inventor of FastAPI is Sebastián Ramírez. He’s a man with a fabulous mustache and an intense — some might say feverish — need to express himself with emojis. Falcon vs. FastAPI I’m embarrassed that FastAPI is so fast. I’ve preferred the Falcon web framework when I wanted speed and didn’t need Django’s ORM. “Async Python is a crock,” I mumbled to myself as I fell asleep each night. Nothing can beat a Cythonized Falcon deployment, right? It turns out I was wrong. NOTE: All comparisons between Falcon and FastAPI in this post are between Falcon 2 running as a synchronous WSGI application and FastAPI running as an async ASGI application. As of version 3.0, Falcon now supports async Python, wihch I’m sure would do better in a head-to-head with FastAPI. The Impetus Why rewrite a production API, you might ask? Not just for fun. My impetus for the rewrite was that I started maintaining aioredis-py, working alongside some great engineers who were already contributing to the project. The maintainers of aioredis-py were testing a new version, 2.0, which was a massive port of redis-py to support asyncio. We wanted more people to try version 2.0 in running systems before we graduated the release from alpha to beta. My team at work wasn’t using aioredis, so I found an API I could make async with low risk: a full-text search API that indexes Redis Labs web sites and exposes an API for searching them with Redis. Using Falcon as the web framework and Redis with RediSearch for the data layer, this