Modern APIs with FastAPI and Python Transcripts
Chapter: Deploying FastAPI on Linux with gunicorn and nginx
Lecture: Create a cloud server

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Here we are inside my Digital Ocean account.
0:02 Now over under these projects, we've got Talk Python and we've got this thing called Playground.
0:07 If I were to click on Talk Python,
0:09 You'd see we have a whole bunch of servers that are hosting many services and databases
0:14 and all sorts of stuff going on over there.
0:16 But this one is just a nice little empty space where I can work.
0:19 So this should look roughly like what you would have.
0:22 Now, here's the platform as a service,
0:23 this apps thing. But what we're going to do is just create a droplet. A
0:27 droplet is, you know, code word for "I'm going to create a virtual machine".
0:30 You can see you could create a server based on many different versions of the operation system.
0:36 we could do FreeBSD, Fedora,
0:37 Debian and so on. And then within those you get to pick which version. I
0:41 recommend if you go with Ubuntu you
0:42 pick an LTS long term support version.
0:45 Otherwise, you'll stop getting updates and that won't be fun.
0:47 We'd also go for containers. You can go to this place called the marketplace,
0:52 and it will let you, like,
0:53 grab a pre-configured WordPress server or whatever.
0:58 But that's not what we're doing.
0:59 We're gonna create a distribution, and then you pick
1:02 well, what kind of server do you want?
1:04 I'm gonna pick the $5 server for this one.
1:06 Now you might think, Well, this is a toy server. It's not really gonna be able to do much.
1:10 But these servers can actually handle a lot.
1:13 And Python does not put much of a load on these servers.
1:17 It depends on what you're doing,
1:18 but this little wimpy server, unless you have got some kind of crazy computation stuff
1:24 going on, if it's a relatively standard Web application,
1:28 it should be able to handle multiple millions of requests per month.
1:31 So it's actually a pretty good starting point.
1:34 The next thing we're gonna pick,
1:35 we could add an extra hard drive,
1:36 we don't care about that. You might need that,
1:38 if you had say, like,
1:39 tons of data in a database,
1:40 you want to put that over there.
1:41 Could make sense. We're not going to do that.
1:43 Now you want to pick a data center that makes the most sense for the
1:47 consumers of your application. For many of us,
1:50 that probably means either Europe or the East coast of the United States.
1:55 For us, our servers are in New York City.
1:58 The reason is that's good for all of the United States
2:01 and North America. It's also pretty good for Europe because it's a straight shot across the
2:07 ocean, so that covers many of our users.
2:10 We also have people all over the world,
2:12 you know, places that are far from there,
2:13 like Australia, New Zealand, which is not ideal.
2:16 But we got to pick one place and just for us,
2:18 East Coast of the US made a lot of sense.
2:20 However, I'm on the West Coast.
2:22 So just to keep things quick as local,
2:25 we're gonna pick this,
2:26 right? So you pick the one here that makes the most sense for you.
2:29 Just be careful. If you're gonna create multiple servers like a Web server and a
2:33 database server and you want them to talk to each other,
2:35 it's much, much better If they're in the same data center.
2:38 We could use VPC, virtual private networking.
2:41 It's on by default, but we're not going to do anything with it.
2:44 Might as well turn on monitoring.
2:45 This lets us look at the server through some of the management tools here.
2:49 We're going to use an ssh key which allows us to just log in,
2:53 and just go ahead and type "ssh" and go and register the ssh key.
2:56 We won't have any username or password to mess with.
2:59 Going to turn them all on.
3:02 Here's the project it's gonna go into, in playground.
3:04 You could turn on backups, we're not doing that.
3:07 So watch how quick this is.
3:08 Oh, I should have given it a name.
3:10 Oh well. Yeah, be sure to give us a better name,
3:12 but I'm gonna leave this going in real time so you can see how long it
3:15 takes. So I'm not going to cut anything out here.
3:17 I'll just keep kind of rambling on. It
3:20 should take usually about 30 seconds.
3:22 So virtual machine is there. I think it's probably starting right now.
3:27 Maybe some final startup script for the first time of running, and wait for it.
3:31 That's it. I don't know,
3:33 what was that? About 30 seconds.
3:34 We can go back and check.
3:35 But not very long. And so now we have a virtual machine over here.
3:38 We just click that to copy the IP address.
3:42 Ultimately, you want to map
3:43 a domain name over there. But basically we're done with Digital Ocean.
3:47 That's it. That was all of the Digital Ocean that we care about.