Async Techniques and Examples in Python Transcripts
Chapter: asyncio-based web frameworks
Lecture: Review: Request latency again

Login or purchase this course to watch this video and the rest of the course contents.
0:00 It may have been awhile since you're seen
0:01 the opening async chapter where we talked about
0:04 synchronous execution and response time
0:06 and why that is versus asynchronous execution.
0:09 As I've said before this is how we opened the course
0:12 but just to remind you
0:13 we'll go through this super, super quick
0:15 we have three requests that come in.
0:17 They each take the time that the green box
0:18 with their name on them takes
0:20 so request one and request two take awhile
0:23 request three not so long.
0:25 We want to know how long does it take from the outside
0:28 how long does it appear for this processing take
0:31 to the client. If we have a single threaded synchronous set of
0:34 executions in our web app.
0:36 Well, response one looks pretty good
0:38 about the same time we, I guess, expect it to take.
0:41 Response two however, is pretty shabby.
0:43 And if you look how short request three is
0:45 it turned out to be like five times as long
0:48 as it should have taken
0:49 because it didn't get a run for so long
0:50 it's all queued up. If we can take the places
0:53 where our web app is mostly waiting on a database
0:56 waiting on a web service waiting on a file system
0:59 all those things and wrap it up in asyncio
1:01 we can take this graphic and make it way better.
1:04 Looks more like this. We can start processing request one
1:08 as soon as it starts waiting and
1:10 request two comes in we immediately can pick it up.
1:12 Similarly, when we get to three
1:14 the first two are waiting again
1:15 on something like a database
1:17 we just hand out that response right away.
1:18 So it looks more like this.
1:20 Yeah, you can't actually make them go faster
1:22 but in terms of latency
1:24 well, things look a whole lot better.
1:26 This is the type of system we're going to build
1:28 right in this chapter using a Flask.