Full Web Apps with FastAPI Transcripts
Chapter: Deploying FastAPI on Linux with gunicorn and nginx
Lecture: Surveying some hosting options
0:00 I often get asked: where should I host my web app? my Python web app? People either ask me that after taking one of my courses
0:07 or they'll ask me how to do that because of the podcast or something along those lines, and I have one answer that I typically give.
0:15 But I want to talk about the spectrum of the options here because not everyone fits
0:19 into the same bucket. So at the, probably easiest to get started and certainly easiest
0:25 to operate, we have these platform as a service type of hosting environments for Python
0:31 web applications. So Heroku has been hosting many web applications as a platform as a service, and they have great Python support.
0:40 So what does platform as a service means? It means you'll do something like point, you know, connect Heroku to a GitHub repository,
0:48 if that repository has a requirements.txt or other Python indicators right at the top,
0:53 it will automatically determine that it needs to run under Python. You add a file to say here's the execute command, and it'll just go on, create
1:01 a server, set it up, make sure it runs. You push a new thing to that GitHub repo, you'll grab it,
1:07 redeploy it with zero downtime, all of those kinds of things. So this is super helpful, but you don't have as much control here,
1:14 right? You've got to fit into their ecosystem. You want to use a database? Great, you're probably using their hosted database,
1:19 which is not that cheap, honestly, depends on where that money is coming from and what you're doing. But it's not nearly as cheap is doing it yourself,
1:26 that's for sure. So Heroku is actually, if you're very unsure about working with things like running and maintaining Linux servers and virtual
1:35 machines and stuff, Heroku or other platforms as a service are a really good idea to get started. My favorite place for hosting is Digital Ocean,
1:44 and in fact, at the time of the recording, all of the infrastructure for Talk Python Training runs over at Digital Ocean.
1:51 We've got about eight servers there, and we do all sorts of interesting things with them to make all of our
1:56 APIs, our APPS and our web app and whatnot go. Digital Ocean just launched something like a platform as a service that Heroku has, called their app
2:05 platform. So you might consider using that, Python is definitely supported there. What I use is just their, what they call droplets.
2:11 This is their virtual machines you can go create. Notice, starting at $5 a month. So for literally $5 a month, we could get this Python FastAPI
2:20 up and running, no problem. We have a lot of database requirements? Maybe we've gotta add a dedicated database server. If it's very, very lightweight,
2:29 maybe we could actually put it on the same server. Anyway, it's quite cheap to get started. Linode is also really good,
2:35 and they're comparable to Digital Ocean in that they have hosting of like these droplets, these virtual machines. They don't call them droplets,
2:43 but same idea. They also both Digital Ocean and Linode have kubernetes clouds or clusters, if you want to run Docker.
2:51 I'm not necessarily recommending that, but it's you know, if that's the way you wanna go, they both have great support for that.
2:57 Also, notice up at the top here, this URL talkpython.fm/linode If you do want to go to Linode, use that and you'll get
3:05 $20 off, get a $20 credit towards your account. Not gonna change the world and I, it just lets them know that I'm sending people over.
3:12 I don't actually get paid, this is just part of their sponsorship of the podcast. But, you know, it'll give you guys a little bit off
3:17 so go ahead and use that if you feel like it. Next up, we've got a couple of the big ones. We've got a AWS. Now, AWS is amazing,
3:24 I use AWS services for various things, like generating transcripts, the first pass
3:29 of transcripts for the courses. Delivering some of the video content and things like that. But I don't host my service there.
3:35 I think AWS is massively complicated and massively expensive. To run that $5 VM we saw over at Digital Ocean or the similar one at Linode,
3:44 how much does it cost? About %50 - $60 a month for exactly the same thing. Yeah, and the thing is,
3:50 it's super, super complicated because AWS runs extremely large scale applications, things like Netflix and so on.
4:00 So all the tooling is really dialed in for these advanced use cases, which means the simple case is not so simple.
4:08 But there is a simple, simplified version of AWS, if you guys are over there,
4:12 it's called Amazon Lightsail. And to run that $60 server over a normal AWS, you can get it for $3.50 on lightsail. Go figure,
4:21 it's very weird the fact that they have these two things, but they do and my theory is that this is a direct response to Digital Ocean
4:29 and Linode, and it's a very similar and simple way of creating things, so you might consider it. Again, I'm, I'm sticking with Digital Ocean.
4:37 We also have Microsoft Azure, they let you run web apps as VMs, they let you run web apps as a platform as a service
4:43 as well. So those are the hosting places that I would first go look at If I was hosting my stuff on the Internet.
4:50 If I was was trying to take this FastAPI we built, put it somewhere that has good data centers, has good reputations, has good pricing,
4:57 at least you know, excluding the bare VMs that say AWS and Azure. But the, one of the uniform
5:05 things about this, all of them,is that they're gonna ultimately run on Linux.
5:09 So final thing, we're really in this chapter gonna just focus on getting our
5:15 FastAPI running on an Ubuntu virtual machine in the cloud. We're gonna actually
5:20 create it on Digital Ocean, but that's just like a few clicks in some web app. And then, you know, you won't even know what server,
5:27 what host you're on. You're just gonna log into the server remotely and do a bunch of steps. So really,
5:32 what we're gonna do is figure out where we're gonna run our Ubuntu virtual machine and on the platforms as a service,
5:37 even when you're not directly interacting with that server, you really are running on some kind of Linux machine the vast majority of the time.
5:45 So understanding what's going on under the covers is probably a good idea anyway