MongoDB with Async Python Transcripts
Chapter: Welcome to the Course
Lecture: MongoDB is fast
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
One of the reasons that MongoDB is loved is because it's fast.
0:05
Not only is it fast, it's actually quite easy to build applications that are fast with MongoDB as well.
0:12
You don't have to think so much about joins and all of these types of things, as we'll see. So you're taking this course here at TalkBython training.
0:20
Let's give you some numbers. Let's give you some perspective on an app that I hope I imagine felt really quick to
0:27
you and how that's working running on top of MongoDB. Over here we have our courses page. Here we've got quite a number of courses.
0:39
We've got which ones are new. We've got which ones are free. We've got all sorts of information about them, when they were released, their pricing and
0:46
so on. Now on this particular page, you can see it has account and logout, so it has to have
0:51
information about who is logged in, as well as the courses and other things. So on this
0:58
particular page, there are four separate MongoDB queries, plus the page logic. And if we measure
1:05
the time of request hits the web server, not the database hits the web server, does all
1:11
that logic and processing can it calls MongoDB four times, it takes those results back, it
1:18
turns them into Python objects, then it turns that into HTML and HTML is then rendered back
1:26
out so complete round trip, not just to the database, but actually through the web request
1:32
and the end, those four requests, only 33 milliseconds on average for this page, 33 milliseconds and this is on a 10 or $20 server.
1:43
This is not on some insane, hugely expensive server running in the cloud. It's a pretty standard one.
1:51
So if most websites out there had 33 millisecond response times, the web would be a better place, wouldn't it? One more.
1:59
When you go to watch a course on our website, there's a whole lot of information that has to come back.
2:06
Maybe the course has 50 or 100 videos that are associated with it.
2:12
We like to keep our videos really short so you can jump around and use them as reference.
2:16
We need to know how long is this course, what is this repository, what are all of its chapters
2:22
and lectures, do those lectures have transcripts, again are you logged in, do you have permission to access this, many things.
2:31
For this page, we actually have 10 MongoDB queries, which surprised me when I went to check that out. That's fine.
2:38
10 queries plus the page logic and some of those collections, MongoDB's term for tables, have millions of records in them.
2:50
And we need to get many results, but you know, focus down to you and this particular course,
2:57
but still many results back potentially from those millions that are in there. How long does this take? It must take forever, right?
3:04
It must just spin and spin. Nope. had it an entire four milliseconds for this particular page. None of this is cached, not
3:14
the example before, not this one. These are live requests going through Python talking
3:18
to the database every single time. How awesome is that? Such a cool system we got going here.
3:27
Not because we're awesome, but because we built on awesome technology such as MongoDB.
3:34
of the techniques I've used to make this page incredibly fast. I'm going to teach you throughout
3:39
this course. Some are obvious, some not so much, and I think you'll really enjoy it.