Long before Python 3, and ChatGPT, and TikTok, poor developers had to write their web servers using shudders Python 2 native features. This meant no asynchronous operations. The frameworks that arose from this era proliferated and became cornerstones of web development. There might even be a synchronous Python web server showing you this text right now. But things change, and with Python 3’s native support of asynchronous operations came a new standard - Asynchronous Server Gateway Interface (ASGI). By vidavolta.io.
The article then explains:
- First things first - the synchronous approach
- Asynchronous web servers
Asynchronous web servers are fundamentally different in how they handle requests and concurrency. They will run a main process - essentially a task manager, that schedules requests to be executed. The key distinction here is that tasks will return control to the task manager when they need to wait for asynchronous work - like in the case of an expensive network call.
We explored synchronous and asynchronous Python web servers and showed that for heavily IO/Network bound workloads, the (relatively) newer ASGI compliant web servers can be far more performant than WSGI servers.Interesting read!
[Read More]