This course has been updated! We now recommend you take the Full Stack for Front-End Engineers, v3 course.
Transcript from the "Exercise 9: Buy a VPS" Lesson
[00:00:00]
>> Jem: We're gonna buy a VPS now. We're gonna buy your very own server that you can know and love and play with and destroy, delete, do whatever you want. So let's go to digitalocean.com,
>> Jem: Again I'm not sponsored by DigitalOcean. I've just used a bunch of interfaces. Theirs is the most friendly.
[00:00:18] So, I'm gonna show you AWS for now, and while we're not using [INAUDIBLE] So this is DigitalOcean, so if I wanna create a droplet which we will do in a second. [SOUND] Look at this nice pretty user interface, this is good looking. This is a good UI. Now this is an AWS.
[00:00:43] Yes, this is why we're not using AWS, it's very intimidating. It's a very, very powerful system but this is not user friendly at all. So if I wanna make a server on AWS, call it EC2 instance. So I'll click on EC2, I'll say, launch instance. And then I have all these kind of options to go through.
[00:01:08] Yeah, we are not using AWS, this is why, because it is very very powerful, but with power comes-
>> Speaker 2: We actually do have a course that is coming out on node, basically, full stag node or whatever, production node, I think is what the course will be called. And it he, Kevin, shows how to configure all this stuff.
[00:01:29] How to use Elastic Beanstalk, so that as he's using a Python script. To hit it with tens of thousands of users. And then it autoscales with Elastic Beanstalk, the AWS [INAUDIBLE] So I encourage you to check that out if that's interesting to you. Auto scaling and that kind of stuff when that course comes out.
[00:01:52]
>> Jem: Yes. Can they hear you?
>> Speaker 2: Yeah.
>> Jem: Okay, perfect. Yeah, there is a [INAUDIBLE] course coming out. And AWS is infinitely powerful. You can literally build anything with AWS. But for a beginner class, we're definitely not gonna go there. And back to DigitalOcean, much, much easier. So we're gonna create a droplet now.
[00:02:20] A droplet is DigitalOcean's way of saying a VPS just like on AWS it's called an EC2 instance. So they're equivalent. So make sure we're using Ubuntu,
>> Jem: .10.
>> Jem: Yes, let's make sure, okay? This is really important that you're using the correct version of Ubuntu. If you're using the wrong version, things will not work correctly.
[00:02:50] Or they'll work differently than expected. When we choose a size, let's choose the smallest one. So, this one is $5 a month. Since everybody got a [LAUGH] all those free credits, we, you should be able to run your server for two months without paying anything. We're not going to add any block storage.
[00:03:08] Pick a data center that is closest to you. So if I was running a server for my personal use I'd use San Francisco cuz that's the closest to me. It's gonna have the least amount of latency. But use a server that's the data center is closest to you.
[00:03:27]
>> Jem: Back to the version, the version is 1610. So put it there. And silly question, why do we want the data center closest to, like say you're building a company, why do you want the data centers closest to your users. Exactly, latency, so if I make a server in Singapore it's gonna take me forever cuz remember how we used trace route to see all those hops?
[00:03:56] There's gonna be a lot more hops to get to my server. And that costs expensive, 100 milliseconds matters in terms of conversion rates for building a business. So you always wanna choose a datacenter that's close to you. When you're more advanced we'll actually make, not today but we can make a server on every single one of these data centers so that no matter where you're at in the world you can have a server that's close to you.
[00:04:19] So let's add an SH key. I'll go back to the slide for this one.
>> Jem: Data center. So we're gonna add our SH key. So, what you wanna do is, back in your terminal,
>> Jem: Just cat your SH key. Cat is just a way of displaying a file.
[00:04:43] And make sure it's your public key. The one the ends in .pub. So if use the my key nomenclature it will be my key.pub this is confusing too you because product keys don't have an ending. So you're like, which one is it? Just remember .pub.
>> Jem: There's a question.
[00:05:06] If I'm in Singapore, should I choose Singapore? Yes. Use the data centers closest to you. It has the least amount of latency.
>> Jem: Another question is what do the numbers on the data centers mean. It's just arbitrary. So Amazon's main data center is in Virginia and it's called US East.
[00:05:28] And the three main ones that Netflix use are US West, US East, and U West, I think. And the numbers are just arbitrary they indicate which specific data center you're at, you can pick one, two or three, it doesn't matter in this instance.
>> Jem: Okay, so-
>> Speaker 2: Its a different physical location so-
[00:05:50]
>> Jem: Yeah, exactly, exactly and it's helpful to know in case say one day center goes out so your UCS1 goes out UCS2 is up and running. [LAUGH] These are for all [INAUDIBLE] that's cracking me up. Okay, so I'm gonna just do this in my terminal. So I'm gonna cats my_key2.pub.
[00:06:23] Okay, so this is one instance where I'm actually just gonna copy paste. It wouldn't normally do this but just copy that.
>> Jem: And just paste in your public key into that. And again, the public key, I can share, put this on Twitter, I can put this on Facebook, it doesn't matter.
[00:06:50] Public key doesn't get you anything? So, feel free to share it around. It won't, I don't know why you would. But don't feel bad if you do. And if you're ever looking for a shortcut and you're trying to remember. Is this my public key or private key? The public key is significantly shorter and smaller than the private key, yes?
[00:07:10]
>> Speaker 2: So mine has my user account at the name of my machine at the end of mine.
>> Jem: Yeah.
>> Speaker 2: Should I leave that in there?
>> Jem: Yeah, leave that in there.
>> Speaker 2: Okay.
>> Jem: Perfectly acceptable. Just, for reference, this is what it looks like when I cat my public key.
[00:07:24]
>> Speaker 2: If yours doesn't, does that-
>> Jem: It's fine, too.
>> Jem: Okay, so paste that in. Give it a name that you'll remember. So I'll just call this front end master. Francois has a good tip. If you are on a Mac, you can use pbcopy and that will copy things to your clipboard.
[00:07:45] So I can say cats, think I have pbcopy in and then I'll copy it to my clipboard.
>> Speaker 2: There's a question about why would one share his or her public key?
>> Jem: I don't know why you would share your public key. Actually, no, if you say your friend made a server, and you don't wanna share your password out, obviously.
[00:08:15] So you give him your public key and only you can log in to that server. It's a fairly useful authentication method, but, great question.
>> Speaker 3: Does DigitalOcean have a limit on the public keys that you can add your account?
>> Speaker 2: You can just copy it.
>> Speaker 3: When we generated a key on this computer, I've got another computer at home, and maybe I'll just generate another key.
[00:08:40]
>> Jem: I've generated up to about ten without any issues. I'm sure there is an upper limit, but I haven't hit it. So probably like 50 or so, I'm just guessing.
>> Jem: Okay, so we add our SSH key.
>> Jem: I'm gonna give, everybody with me so far? It's good, okay.
[00:09:05]
>> Jem: Just gonna add that SSH key.
>> Jem: And you can call it whatever you want. Whoops. Why Singapore? Let's do San Francisco. There we go.
>> Jem: And remember, naming your server is important because you can only name it once. So, give it a good name. There's a good xkcd on naming a server.
[00:09:25] Actually, no, I won't look it up.
>> Speaker 2: There's a good xkcd on everything.
>> Jem: Yeah. But, give your server a good, meaningful name because it will be with you for the life of the server. But it doesn't really matter, you can name it whatever you want. Okay? So we're all here, we've got our SSH key.
[00:09:44] And we can create a Droplet now. And it's creating.
>> Jem: While it's creating, [LAUGH] Derek asked what do you think about back ups? I remember it being more difficult to turn on than turn off. You should absolutely back up your machine. I believe in DigitalOcean you can just make a copy of the volume.
[00:10:22] The volume is essentially a copy of the hard disk for that image. I do that regularly on my personal machine about every, probably a week or so, I just make the regular copy. Just because A, if you locked yourself out of your server, you do something stupid or someone breaks in, drops a virus.
[00:10:37] Always have a backup, backups are a hassle. But you don't need them so you need them, when you need them, you need them. [LAUGH] Thank you, Samir. [LAUGH] As any experienced engineer will tell you, when you need it, you need it. And if you don't have it, you'll be like why didn't I just spend the extra five minutes making a backup?
[00:10:55]
>> Speaker 2: So it's just a cron job then that runs every week that you do? Or, how do you do it?
>> Jem: So with AWS, I can set up a job. Not a cron job, but you can also do a cron job. But I just set up a backup in the AWS console, but great question.
[00:11:08] So if we click in, we see there's no data yet cuz there's nothing happening. But what's important is you have an IP address now. This IP address is your own personal server. So if we just hit Copy and hit Enter, nothing happens. Because there's nothing running on your server yet, it's just at empty blocks, is a blank slate.