Modern APIs with FastAPI and Python Transcripts
Chapter: Deploying FastAPI on Linux with gunicorn and nginx
Lecture: Surveying some hosting options

Login or purchase this course to watch this video and the rest of the course contents.
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 mean? It means you'll do something like point, you know, connect Heroku you 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 and create
1:01 a server, set it up, make sure it runs. You push a new thing to that GitHub repo, it'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 as 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 API's and our apps and our Web app and whatnot go. Digital
1:59 Ocean just launched something like a platform as a service that Heroku who has called their App
2:05 Platform. So you might consider using that, Python is definitely supported there. What I use is just there, 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 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 a 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 want to go, they both have great support for that.
2:57 Also, notice up of the top here this URL "". If you do want to go to Linode, use that and you'll get $20 off,
3:06 Get a $20 credit towards your account. Not going to 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 have 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 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 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, it's called Amazon Lightsail. And to run that $60 server over a normal
4:17 AWS, you can get it for $3.50 on lightsail. Go figure. It's very weird, the fact that they have these two things.
4:23 But they do, and my theory is that this is a direct response to Digital Ocean and Linode, and it's a very similar and simple way of creating things,
4:33 so you might consider it. Again, I'm sticking with Digital ocean. We also have Microsoft Azure. They let you run Web apps as VM's.
4:40 They let you run Web apps as a platform as a service, as well. So those are the hosting places that I would first go look at
4:47 If I was hosting my stuff on the Internet. If I was trying to take this FastAPI
4:51 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 VM's at say AWS and Azure. But one of the uniform things about this,
5:06 all of them, is that they're gonna ultimately run on Linux. So final thing, we're really, in this chapter, going to just focus on getting our
5:15 FastAPI running on a 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.

Talk Python's Mastodon Michael Kennedy's Mastodon