Async Techniques and Examples in Python Transcripts
Chapter: asyncio-based web frameworks
Lecture: Remember to run on an ASGI server
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
So when we talked about the performance and profiling and load testing previously, just the previous video I said you have to run on an ASGI server.
0:10
WSGI, traditional Web Service Gateway Interface that's how Django, Pyramid, Flask, all of them work. They're all based on this.
0:19
Basically the underlying web API that integrates these frameworks into the server those are serial. So there's no way to do asynchronous programming
0:28
or execution for those frameworks at all. So in order to actually get the scalability and to actually execute our code on asyncio event loops
0:38
you have to use what's called as ASGI server. An Async Service Gateway Interface something to that effect. So you can use Hypercorn.
0:47
Hypercorn comes when you pip install quart you get Hypercorn, this is an option. It says you don't type run. You know, don't like just run this here.
0:56
What you're going to do instead is you type hypercorn module name and then app name that you want to run, okay?
1:03
Also lists some others down here, Uvicorn. We talked about uvloop based on that, right? And some of its capabilities.
1:11
So you can see Hypercorn is pretty awesome. I believe it's based on Gunicorn much like Uvicorn is as well and I honestly don't know enough about them
1:20
to like help you decide between one or the other but this one looks like it has more features. That seems good. Make sure if you do any load testing
1:28
or you do this in production that you run it on an ASGI server or you're basically going to get exactly the same
1:34
as what you had with Flask and if that's what you're getting you might as well keep the more well-known well-tested API, right?
1:41
Be sure to use one of these servers.