Skip to content
Browse files

Final transcripts (pending any corrections).

  • Loading branch information...
mikeckennedy committed Aug 24, 2017
1 parent ea126ad commit 050840a4bd994a8b8fef3490239a988d38a84f60
@@ -45,9 +45,9 @@
02:53 tomorrow will be the thirteenth, so 5-13, things like this.
02:56 Now we could have a go both to here and to here
03:00 but you'll see that when we get to deployment
03:03 things like the micro wsgi log catch standard out
03:03 things like the μwsgi log catch standard out
03:06 and put that in there already so you would basically be duplicating
03:08 this log message stuff to the micro wsgi bits
03:08 this log message stuff to theμ wsgi bits
03:11 and you know, you can decide whether you want that
03:14 but I don't think it works out really well.
03:16 So we're going to go like this, let's go back to dev
@@ -0,0 +1,49 @@
00:01 We've reached an exciting point in our class,
00:03 we've basically entirely created our web api,
00:06 and we're ready to deploy it to the cloud, in a full on production environment.
00:11 I hope you're excited, I am. So how is this going to work?
00:14 Well we're going to start out by deploying this to Ubuntu,
00:17 that's this big grayish box here, right so we're going to deploy to Ubuntu,
00:21 and we could have the running across multiple servers,
00:24 with load balancing a lot of things, but for a simple example
00:27 we're just going to put it all on the same machine.
00:29 So the first technology in addition to Linux that we're going to employ is nginx,
00:34 so nginx is going to be the front line web server,
00:38 this is the thing that browsers and other web clients talk to,
00:43 and as far as they know this is the only thing involved in our web processing,
00:46 so then, behind the scenes on the server,
00:49 the thing actually executing Python is going to be μwsgi,
00:53 μwsgi is implemented in C and is specially built
00:58 for running Python web applications, so we're going to run that,
01:03 but we're not just going to have one instance of it ,
01:05 instead we're going to use it in this kind of master emperor mode
01:09 I think it might be called,
01:12 where there's one process, but you actually create many subprocesses
01:16 because Python is not super great at computational parallelism,
01:20 so the way we're going to solve this is just by having many subprocesses,
01:23 it does use threads and as we're talking to things like databases,
01:26 that will do parallelism, but we're going to get additional parallelism
01:29 by having multiple ones.
01:31 So we're going to create a bunch of these,
01:33 and it's actually in these little sub processes where our Python code is going to execute,
01:38 so let's see how this request overall architecture is going to work,
01:41 some kind of request is going to come in from the internet,
01:45 and hopefully, you'll set this up to use https,
01:47 it's really easy to make nginx talk https,
01:50 you just get a certificate, point it at it and say here's your certificate,
01:53 so a request will come in to nginx,
01:56 it's going to handle all the ssl certificate stuff,
01:59 all the static files and things like that
02:01 but when it needs logic, when it needs to do Python stuff in our application,
02:05 it's going to send this request internally
02:08 over to our μwsgi management main process,
02:12 and this is probably over http or just a local socket ,
02:14 and then this thing is going to decide which one of these is going to actually
02:18 do the processing and then it will return the response back,
02:21 so this is what we are going to go now and set up on Digital Ocean
02:24 we are going to create an Ubuntu Server on Digital Ocean,
02:27 we are going to install nginx, we are going to install μwsgi,
02:30 we are going to move our Python code that we've written up there via get,
02:33 and then we're going to see how to configure these things to accomplish
02:37 basically exactly what I have here, except we're not going to do the https part,
02:40 you guys can add that on yourself if you want.
@@ -0,0 +1,63 @@
00:01 Here we are on Digital Ocean,
00:04 you've maybe heard of Digital Ocean,
00:06 I am a huge fan of what those guys are doing,
00:08 you probably heard of things like aws and azure,
00:11 but I'm here to tell you for simpler, not extremely complicated web applications
00:17 that have to dig into all of these cloud apis, this is a better place to be;
00:22 it really is better performance and much, much cheaper, and really just simpler.
00:26 We're going to use Digital Ocean to go create this Linux server.
00:29 Now, let's click really quickly on pricing,
00:32 just so you guys see like what it is we're going to create,
00:34 so the pricing is really nice here, we're going to use a standard droplet
00:38 and pay, we can get hourly price if we want,
00:41 but really monthly is a better human term to think about what is it going to cost us,
00:45 they also have like high memory ones, and whatnot,
00:48 but we're just going to focus down on these standard ones.
00:51 So we're going to use a five dollar server,
00:53 and you'll see that this five dollar server
00:55 will run our api for many, many requests, I'm pretty sure
00:58 we could get millions of requests per month for five dollars.
01:01 And just to indicate like what a good deal this is, last time I checked the pricing
01:06 for just bandwidth alone at aws was nine cents per gigabyte,
01:11 notice you get a terabyte of bandwidth here,
01:14 so 0.09 times that many gigabytes, that's 92 dollars a month
01:18 just in bandwidth value that you get with his thing,
01:21 not to mention you get ssds and all sorts of goodies.
01:24 So what we're going to do is we're going to go create one of these,
01:27 now, I have already created an account, so logged in here
01:30 you can see my various servers that I used to run the Talk Python and Python Bytes stuff
01:35 and we're going to go and create a new droplet,
01:38 so let's go down here and and show you what you get
01:42 so we can come down, we can pick a variety of different linux distributions,
01:45 and pick different versions as well, so let's just go with this one,
01:51 the standard long term support Ubuntu, there's not a real great reason
01:56 to choose a different one, I will just point out though that you can go
01:58 if you want to and get it kind of pre configured, like from my Mongodb server
02:02 I just went down here and said I want Mongodb running on that version of Ubuntu
02:06 and boom, it already comes preconfigured, somewhat secure, things like that.
02:10 But we're not using Mongo, so we'll use this
02:13 and pick this size, you'll see that that's plenty good
02:18 we don't need block storage right now
02:21 we could get a different data center so I'm on the west coast of the US
02:25 so I'll pick something in San Francisco
02:27 and then we just have to create an ssh key, we click go, give it a name,
02:31 and let's call this auto service server something like that
02:37 it seems like a decent name, we can have a bunch,
02:40 I don't want a bunch, I want one, and we'll get going.
02:42 So, that's how it will work, we're going to need to do things like create an ssh key,
02:46 so that we can log in and not have to worry about passwords, and things like that,
02:50 but we'll do that in just a moment, right.
02:53 So Digital Ocean basically lets us create these servers
02:56 and then we can go over to the networking section which we'll do afterwards
03:00 and we can basically get it's called a floating ip address,
03:04 and what that means is there an ip address that kind of
03:07 we control independent of the machine and we can map our domain to that
03:10 and then we can do things like hey I need to upgrade the server
03:13 I could move it over to a temporary fail over server if for some reason
03:17 I want to just create a new version after six months
03:20 on a new implementation of Linux or whatever
03:23 I could spin that up and get it exactly ready
03:25 and then I could just instantly flip the switch, and it will flip to that new server.
03:28 So it gives you a little bit of machine independence,
03:31 with this networking section, so we're going to do that next,
03:34 but first, in order to create this, we're going to create an ssh key.
@@ -0,0 +1,18 @@
00:01 Now the next thing we want to do is create our server
00:04 but before we can do that, we need to give it an ssh key
00:06 that we can use to log in, after it's created,
00:08 this is a much easier and safer way than just using usernames and passwords.
00:12 So click here, it's going to say let's create a new ssh key,
00:16 and you click this link, it takes you over here and it says
00:19 the first thing you are going to do is ssh keygen rsa.
00:22 Now that's close to what we want, it's not exactly really what we're going to need,
00:25 so what we're going to do is we're going to do ssh-keygen -t ssh-rsa,
00:31 not just straight rsa, and it's going to ask us for our files
00:34 we'll say use/screecaster/ .ssh/ and let's call it digital_ocean_course_demo.key
00:44 call it whatever you want, I'm calling it that, no passwords and it's all good to go.00:48 Now if we look in here, we'll see we have a couple of these,
00:51 we have the private key and we have the public key,
00:55 now I'm going to delete this key from my account afterwards anyway
00:58 but let me just offline grab the value and put it into where it's supposed to go.
01:02 Okay I've taken the contents of the public key
01:05 and I put it in here where it's asking for the new ssh key details,
01:11 so that's what we're going to use for creating this server.

0 comments on commit 050840a

Please sign in to comment.
You can’t perform that action at this time.