0:00:00Welcome to Under the Radar, a show about independent iOS and app development.
0:00:03I'm Marco Arment.
0:00:04And I'm David Smith.
0:00:06Under the Radar is never longer than 30 minutes, so let's get started.
0:00:09So last week we mentioned at the end how we were going to tell this week tips and stories
0:00:15and setups of how to run your own Linux servers.
0:00:18Because this is now, you know, in the wake of the parse announcement last week, this
0:00:21is now kind of in the news, and we think it's kind of a core competency that many app developers
0:00:25should know just how to run your own servers.
0:00:27And once you know this, it enables your apps to be better,
0:00:31to be more capable.
0:00:33And if you do kind of a standard server route
0:00:36without doing these kind of more abstract proprietary services
0:00:39like Parse, it gives you a lot of flexibility
0:00:41with what you can do in the future.
0:00:43And it kind of decouples you from depending
0:00:45on a particular third party to keep their platform going.
0:00:49Yeah.
0:00:49And this is probably a fair disclaimer to say.
0:00:51This is going to be an episode that
0:00:52that goes a bit into the weeds,
0:00:54like down at some pretty low level stuff,
0:00:57and if that's for you, awesome.
0:00:59If it isn't for you, maybe stick around,
0:01:01you might learn something, and know that some episodes
0:01:04are gonna be high level,
0:01:05some episodes are gonna be low level,
0:01:07and hopefully we can have a nice balance as a result.
0:01:10So at a high level, it's probably worth starting
0:01:12of just kind of talking about the spectrum of hosting
0:01:16before we kind of end up with why we do it
0:01:18the way we do it.
0:01:19So ultimately, hosting, in many ways, comes down to levels of abstraction, like how abstracted
0:01:26away the actual computer that you're running your servers and your backends and systems
0:01:32on, how much that is abstracted away from you.
0:01:35So at the lowest level, you have what I think would be called co-location or something like
0:01:39that, where you have a computer that's your computer that you went to Best Buy or whatever
0:01:45to buy, and you're taking it and you're putting it somewhere, typically in some kind of data
0:01:49center that you put in a data center so that it has reliable power and reliable internet
0:01:53and reliable air conditioning and all those types of things. But like it's your machine.
0:01:57Most people don't do that. I would really not recommend doing something like that.
0:02:02Most people with the very least we do, but I think most people call like bare metal
0:02:06managed servers where it's not really your machine. It's a service that they buy machines,
0:02:12they manage machines. If a hard drive dies in the machine, they'll go and fix it for you.
0:02:16but it's you have actual like a dedicated piece of hardware
0:02:21you know a set of hard drives, a motherboard, a CPU that's exactly yours
0:02:26and you probably don't want that either I've gone down that road
0:02:29it's fine but it has a lot of
0:02:32difficulties that you aren't really offset by its costs both
0:02:37in monetary and like ease of use so most people
0:02:41who do any kind of hosting themselves will use something that's more
0:02:45like a VPS, which stands for Virtual Private Server, which is basically like, it's a machine
0:02:52from your app's perspective.
0:02:53You are, your app sees a hard drive, it sees a CPU, it sees memory, but all of those aren't
0:02:59actually physical things.
0:03:02It's running on a shared environment with a bunch of other systems that all see the
0:03:06same things and share resources.
0:03:09And you can use something like Linode for this, or DigitalOcean is another one that's
0:03:14That's pretty common in many ways.
0:03:16EC2 kind of runs like this, but it's a bit different.
0:03:19But you have these kinds of systems where you have a virtual Linux machine that you
0:03:23can do, and you have some nice advantages with that because it's virtual.
0:03:27You can do things like pick it up and move it around.
0:03:30You take an image of your hard drive and you can copy it onto another one, and things like
0:03:35that that are really easy to manage.
0:03:37And from a cost perspective, it's way cheaper because you're sharing server resources.
0:03:43And then above that you have things like virtual server environments, things like Azure or
0:03:46Heroku, or total abstractions like CloudKit or Parse or those types of things that are
0:03:52completely abstracting away from you.
0:03:55And like I said, for most people you probably want to start at a VPS.
0:03:57Like you want to find out where you're comfortable if the thought of administering a Linux server
0:04:02even after this episode is completely overwhelming.
0:04:05Like maybe go to something like Heroku or Azure where you have a little bit of control
0:04:10over what you're doing, but mostly there's something there, but it's still at least general
0:04:15purpose. But I think we both run VPS servers because once you know what you're doing, it's
0:04:22really cheap, it's really efficient, and you have a lot of flexibility that you could move
0:04:27providers, you can spin up new servers and take them down really quickly and easily,
0:04:32and especially the cost is amazing. It's incredible the amount of performance you can get from
0:04:38from a really basic setup.
0:04:39I mean, at this point, I think I administer
0:04:4119 virtual private servers or something like that
0:04:44to run my apps, and it's a pretty big number,
0:04:47but the actual load of that,
0:04:49of actually doing that is pretty straightforward.
0:04:51- Oh yeah, and I mean, things have gotten so cheap
0:04:53over the years, like I now pay for all of Overcast,
0:04:56which is something like 11 VPS instances on Linode.
0:05:01I now pay for all of them what I used to pay
0:05:03for one database server for Instapaper back in the day,
0:05:07and that wasn't that long ago.
0:05:08That was like five years ago.
0:05:10So what you can get now at the VPS level
0:05:12is just incredibly good.
0:05:14I was the biggest fan of bare metal dedicated servers before
0:05:17but now even I have converted because you can just,
0:05:20you know, the competition especially between Linode
0:05:22and DigitalOcean has really made incredibly fast
0:05:26hardware available for almost no money.
0:05:28And it also makes it much easier to learn
0:05:30because it lets you, and we'll get into this
0:05:32in a little bit, but it lets you,
0:05:34you know, if you can just like,
0:05:35in a simple command on a web interface,
0:05:38so not involving buying anything,
0:05:40not involving emailing anybody
0:05:42or placing any orders with anybody,
0:05:44just in a web interface you can quickly create
0:05:47an instance of a server, then you can do things like,
0:05:49oh, let me see how easy is it to set up PHP or whatever.
0:05:53Like you can do things like that,
0:05:54or you can say, I wonder how,
0:05:56whether this new distro of Linux makes more sense to me,
0:05:59or I wonder if my software will run on this other distro
0:06:02or this other web server or whatever.
0:06:04you can just spin up a new instance in minutes
0:06:07and run your install script and poke around,
0:06:11try things out, see what works, see what breaks.
0:06:15And if at any point you decide this wasn't for you
0:06:18or this didn't go well, you can just delete the instance
0:06:20and you've paid up to that point maybe 50 cents.
0:06:24Like it's crazy how easy this is
0:06:27to both administer servers and to learn
0:06:29how to administer servers now in the world of VPSs.
0:06:33- Yeah, 'cause it's lovely to think of,
0:06:34most of these are charged by hour of use
0:06:37or something like that, and so you can,
0:06:39they're just kind of like utility in that way,
0:06:41that you can just spin them up when you want 'em,
0:06:43spin, take 'em down when you don't want 'em anymore,
0:06:45and like, it's very straightforward and easy to do
0:06:48in a way that is kind of scary the first time you do it,
0:06:51that you just like hit a button and it's like,
0:06:52oh, here's a machine.
0:06:54Go ahead and SSH into it and get started.
0:06:57- Yeah, I mean, it's so easy that like,
0:06:58you know, one way you could've done it before
0:07:00is by running something like VMware Fusion or Parallels
0:07:02on your computer and virtualizing little Linux setups
0:07:06on your computer and doing that.
0:07:08But now it's so cheap and easy to go do it
0:07:10on Linode or DigitalOcean that it's actually easier
0:07:14to do that than it is to do it on your local computer.
0:07:18Now I do all my experimentation on VPSs.
0:07:20I don't even have virtualization software installed
0:07:21anymore on my Mac.
0:07:23- Yeah, and I'm the same way.
0:07:24The only thing I use my Mac for when I'm doing
0:07:26this kind of thing is the first level of,
0:07:30the nice thing about using something like Linux
0:07:32is that the basic underpinnings underneath our Macs
0:07:36are like it's some kind of Unix-based thing.
0:07:40I couldn't tell you all of the history of it,
0:07:41but functionally, your Mac is running
0:07:43the same basic stack kernel types of things
0:07:46that your ultimate server is gonna run.
0:07:49And so I use my Mac because I can learn
0:07:52and kind of prototype and try some of the things
0:07:54that ultimately I'm gonna run on my main server locally.
0:07:57I have a development database that runs on my machine.
0:08:01I have a web server that runs on my local machine,
0:08:03which makes prototyping really quick.
0:08:05But as soon as I wanna do anything
0:08:06that's going to be simulating my end environment,
0:08:10I just spin up an instance and run it.
0:08:12And I have a couple of just instances
0:08:14that you just bring up, like try it out.
0:08:16If it works, great.
0:08:17If it doesn't, you can just delete it and start again.
0:08:20So once you've decided you're gonna build
0:08:23a Linux instance and get started,
0:08:26and that actual process is pretty straightforward.
0:08:29you'll go to a virtual private server provider, and just sort of you'll set up your instance,
0:08:35it'll give you some credentials and an IP address and a few things that you'll have
0:08:39for like how to log into it, and then you just log in and get started. And for most
0:08:43applications, you're going to install at least two things on that. You're going to install
0:08:47a web server and a database of some kind. And starting out, you could probably put them
0:08:52both on the same machine. Eventually, you'll probably do a thing where you'll split the
0:08:57the web database onto its own machine
0:08:59and put one or more web servers in front of it.
0:09:02But at the very least, you're gonna install
0:09:04some kind of web server environment,
0:09:05some kind of database.
0:09:07The web server that you choose is entirely up to you.
0:09:09Like, I use Ruby on Rails for all my backends.
0:09:12I think all of yours are in PHP.
0:09:14- Yeah, I mean, and I have many opinions
0:09:17on how you choose these tools.
0:09:20I will summarize them, for the sake of this
0:09:21being a short show, I will summarize them
0:09:23as what you want most of all when choosing server software,
0:09:27if you don't wanna be administering and tweaking
0:09:30with your server constantly,
0:09:31what you want is old, boring, and popular.
0:09:35Those three things, old, boring, and popular.
0:09:38New and trendy does not necessarily always mean better.
0:09:41In this case, you know, especially like,
0:09:44what makes some people think that the new stuff is better
0:09:47is vague claims of it being quote, scalable,
0:09:51And beware of any claims of things being scalable, because in reality, scaling web services up,
0:09:58not only is it the kind of thing that you will probably never need for almost any project
0:10:02that you do, but when you do need it, it is way more complicated. And there is no silver
0:10:08bullet for scaling. There is nothing that automatically scales, unless it also automatically
0:10:13scales all of your money away. But there is nothing that automatically and easily scales.
0:10:18Scaling is always complicated and always tricky. It's just, you know, the new things that
0:10:22claim scalability just scale differently. And the challenges are just different challenges.
0:10:29The newer something is, the trendier or newer something is, that means, you know, the fewer
0:10:35people have experience with it and the fewer large installations it has. And so that means
0:10:43there's less knowledge in the world about how it fails or what the anti-patterns of
0:10:47it might be. So as you go lower level in the stack, being this kind of conservative, preferring
0:10:53things that are old, boring and popular becomes more important. So like if you want to use
0:10:58like a brand new cutting edge CSS library, go for it. It doesn't matter really. You
0:11:02know, if it works for you, go for it. Your risk is pretty low there. But you probably
0:11:07would not want to use a beta version of the Linux kernel. You know, so like as you go
0:11:12down the stack, you want to be more conservative because it's just kind of a bad idea to
0:11:17to take risks lower down.
0:11:18And I include things like the database in that.
0:11:21MySQL and Postgres are great.
0:11:24They're battle tested, they are old, boring, and popular.
0:11:27That is what you want in your database.
0:11:30Just like you wouldn't want a trendy new kind of brakes
0:11:32on your car.
0:11:33Like you want time tested brakes that everyone knows works
0:11:37and everyone knows that you aren't gonna be pushing
0:11:38the boundaries of them.
0:11:40You want a really boring database.
0:11:43And I would say you want a really boring language too
0:11:46because really new cutting edge languages are still in flux.
0:11:51And so if you want to have this kind of like set it
0:11:54and forget it kind of server approach,
0:11:56you don't want to have to deal with
0:11:58a young languages frequent changes
0:12:01and frequent needs for being updated.
0:12:04You know, you want to minimize anything
0:12:06that will require your attention
0:12:08or that might break your app.
0:12:09So you wanna minimize the need for, you know,
0:12:12backwards incompatible updates and things like that
0:12:15or crashes and having to install little bug fixes constantly for the language or database
0:12:20you're using, you want to avoid all of that. Because new really, new means untested or
0:12:26less tested. Another thing that you hit with new stuff is in the language layer, new means
0:12:33that you have fewer third party libraries and generally less third party code. And this
0:12:38is a problem like, I've been using PHP forever and PHP third party code is mostly garbage,
0:12:43but there is so much of it out there that any need that I have, I can find something
0:12:49to do it. And it isn't always good, but I can find something. And as I've started
0:12:53writing some newer things in Go, and Go I like as a language conceptually, but because
0:12:58it's such a younger language and it isn't that popular yet, and might never become popular,
0:13:04who knows, but because it's younger and less popular, there is very little third-party
0:13:08already go code for some very common things that I keep needing to do. And I keep, every
0:13:13time I need to write something new in Go, I hit this wall of, "Oh, I'll just load up
0:13:17the markdown module." And I look and there's like three of them that are all kind of half
0:13:22baked and, you know, and I haven't listened in a while for markdown, so maybe that's a
0:13:25bad example. But I keep hitting that wall whenever I do anything in a new language of,
0:13:29"Oh, I just want to see how, oh, how do I resize an image? Oh, well, you kind of can't,
0:13:33"Oh, unless you do this."
0:13:35So it's always easier to use old, boring, and popular stuff.
0:13:39It may be less interesting,
0:13:40and if you are the kind of person
0:13:42who wants cutting edge languages
0:13:45and who finds that satisfying,
0:13:46then you will trade time and maintenance for that.
0:13:50And so for the goal of low maintenance
0:13:52and low server maintenance,
0:13:55I highly suggest that you use other parts of your app
0:13:58to get the kind of newness out of your system.
0:14:01Like yeah, use the higher level parts
0:14:03use maybe the iOS side of it if you have an iOS and a web app, use that side of it to
0:14:07do new cool stuff and make the server as boring, old and popular as possible. Because old,
0:14:12boring, popular stuff works. It really works. It hardly ever breaks and you will never be
0:14:19the biggest person using it because long before, you know, even suppose that you build something
0:14:24with old, boring stuff. Suppose it gets like the size of Etsy, right? Etsy is huge. It's
0:14:29It's not the biggest website on the internet,
0:14:31but it's huge, right?
0:14:32It gets the size of Etsy.
0:14:34If you get that big, will you be the biggest user
0:14:38of anything in your stack?
0:14:40Because once you're the biggest user
0:14:41of your database or something,
0:14:43then you basically become a developer of that database.
0:14:46You will hit all the bugs, you will have to go in
0:14:48and make patches yourself to customize things
0:14:50that aren't working well or aren't working right for you.
0:14:54So Facebook rolls out tons of patches and things.
0:14:57Twitter has rolled out tons of patches
0:14:58things like Memcache, I mean like there's all these big companies, all these big web
0:15:02companies end up having to basically partially take over parts of the stack they depend on
0:15:07open source wise and make their own contributions and fixes because they hit tons of bugs. You
0:15:12never want to be the biggest user of anything in your stack. And you know, when you start
0:15:16out of course you won't be the biggest user of basically anything, but you could become
0:15:19the biggest user. Like you'd be surprised, you know, you hear about new trendy things,
0:15:24but you'd be surprised how few big companies
0:15:27actually use them, so you never want to be the biggest
0:15:29user of anything, you want Facebook to have fixed
0:15:32every bug in that stack years before you ever hit it.
0:15:35- Yeah, and I think we're both coming at it
0:15:37from the perspective of being app developers,
0:15:39like what makes our apps cool is not the backend stack.
0:15:42That's got nothing to do with the thing that I'm gonna
0:15:45be marketing my app as.
0:15:47Like my customer shouldn't care, it's only,
0:15:51it exists for the sole purpose of just getting
0:15:53job done. Most of my backends are the most ridiculously boring, simple applications that
0:15:59I can possibly make it. I put as much logic and smarts as I can in the apps itself. The
0:16:06database is mostly just a nice wrapper for a database, and something that's simple and
0:16:10straightforward that I can set up and then I never think about again. The only time I
0:16:16ever really think about my servers is when there's some big security thing that I need
0:16:22to make sure it was auto-updated,
0:16:24or I'm adding major new functionality to the front end,
0:16:27to my applications, and then I have to go back
0:16:30and add something to it.
0:16:33But otherwise, I just want it as simple and basic as can be.
0:16:35It's just like a big database that I can put things in
0:16:39and then later get them out.
0:16:41And as long as I can do that, I'm good.
0:16:43- And if anything, when you're using old, boring,
0:16:45and popular, if anything ever goes wrong,
0:16:48or if you have any questions whatsoever,
0:16:51or anything comes up, you can just search the web
0:16:53and you have hundreds of answers from the thousands
0:16:56of other people who have used that already
0:16:58and have documented it like three years earlier.
0:17:00(laughs)
0:17:01It's so much easier to make your server side stack
0:17:06something that you can easily forget about most of the time
0:17:10and you don't even have to deal with it.
0:17:12- Exactly.
0:17:13And I guess once you decide on which one you wanna do,
0:17:16it's like the process from there is honestly
0:17:18pretty straightforward.
0:17:19you pick something, you install it. Usually these kind of things are a pretty straightforward
0:17:24install process. Like, if you're, there should be some kind of conversion of like,
0:17:28"Go get me MySQL, go get me Postgres, go get me Nginx, go get me Apache," and the server will go
0:17:36get it, install it, configure it, you'll change a few configuration files, and you'll be up and
0:17:40running because it's boring. And the process of getting it set up has been done by thousands of
0:17:47people so everything's automated and scripted and the only thing that I'd mentioned there
0:17:51is one thing that I learned early on is once I set up a server the first time for I always
0:17:58document how I did it like the steps I did and then I will usually destroy what I did
0:18:02the first time and do it again to make sure I actually know what I'm doing to avoid the
0:18:06situation where down the road you are trying to like recreate a web server and you can
0:18:11never get it to work quite right and it turns out it's because the first time you did it
0:18:15you did this step that you forgot to document.
0:18:17And so that was my first little pro tip,
0:18:21is the first time when you think you got it right, that's great.
0:18:24Now do it again.
0:18:25Because if it works the second time,
0:18:27then you know you actually understand your setup
0:18:30and will be able to do it multiple times
0:18:32if down the road you need to.
0:18:33Because when you need to do it down the road,
0:18:35it's usually under some kind of duress, because you're like,
0:18:39wow, things are going really well.
0:18:40I need another web server to keep up with the load.
0:18:43Like that's a good thing, but it's also a bit of an urgent thing.
0:18:45Yeah, and VPSs make this so much easier because not only can you like, you know, you can just
0:18:49clone a server you already have if you need to, but also like you can do things like,
0:18:53you know, automate this with a big shell script as you figure out, like this is what I do,
0:18:56whenever I have to install something new or change something, I format everything I'm
0:19:01doing as a shell script as I'm going, and then I can rerun it on a fresh server from
0:19:07a VPS, like you know, so it's just like what you said, that you can kind of verify your
0:19:10work and it's so much easier.
0:19:12Oh man, it's like doing this, and I should also say,
0:19:15like, anything that is not really easy to install
0:19:19from a package manager, like, if,
0:19:21suppose you're looking at, you know,
0:19:23I'm looking at some PHP library to manipulate an image
0:19:26or something, you know, this is just a weird example.
0:19:28And if there's like three of them,
0:19:30and one of them is in the repository
0:19:33that my server comes with, like the yum or apt-get repo,
0:19:36like, one of them is in the repo,
0:19:38and I can install it with one word on the command line,
0:19:42and one of them needs to be built from source,
0:19:44I'm going with the one in the repo.
0:19:46Because that's like, anything, as a general rule of thumb,
0:19:50anything that you need to build from source
0:19:52or manually download from somewhere
0:19:53that is not in your package manager,
0:19:55try to avoid needing that.
0:19:58And everything becomes a lot easier.
0:20:00And package managers are not flawless.
0:20:01Sometimes you'll hit some weird conflict,
0:20:04but that's very rare, especially if you stick
0:20:07with the default repositories that come configured with it,
0:20:11because those are so heavily tested by other people,
0:20:14as again, old, boring, and popular,
0:20:16that you might not be able to use the newest version
0:20:18of something or a cutting edge feature of something
0:20:20or an obscure module of something.
0:20:22But if you can get away with not using it,
0:20:25you are saving yourself time in the future.
0:20:27- Exactly.
0:20:28- We're sponsored this week by our friends at Igloo,
0:20:31the intranet you will actually like.
0:20:33With Igloo, you don't have to be stuck at your desk
0:20:35to do your work.
0:20:36You can manage your task list from your laptop
0:20:37during a meeting, you can share status updates
0:20:39from your phone as you're leaving a client site. You can even access the latest version
0:20:43of a file from your home. Whether you're wearing pants or pajamas or anything, nobody will
0:20:47even know. These days, everything is mobile. Your work should be too. Now, if you've ever
0:20:52looked at a corporate intranet, you've possibly thought, "Whoever designed this must truly
0:20:56hate me and everyone I know." With Igloo, those days are over. Igloo internets are actually
0:21:02places you want to be. They're surprisingly configurable. You can even customize it and
0:21:06and rebranded to give it the look and feel of your team.
0:21:08They have group spaces, role-based access permissions,
0:21:10easy to use drag and drop widget editors,
0:21:13so you can reorganize the whole platform
0:21:14to fit exactly how your teams work.
0:21:16Now of course today, mobile is everywhere.
0:21:18Igloo is great on mobile.
0:21:20They are fully responsive, they work on every device,
0:21:22at any screen size.
0:21:24New devices come out, they work on day one,
0:21:26and they have all these great integrations
0:21:28with modern services that you actually use.
0:21:30Things like Box, Google Drive, Dropbox,
0:21:33All of this is integrated into one big,
0:21:35easy to secure platform.
0:21:37They do things like 256 bit encryption,
0:21:39single sign on, active directory integrations.
0:21:41You, if you know what any of those things are,
0:21:43you know how safe and secure igloo is.
0:21:46So share your files with your coworkers
0:21:47for everyone to collaborate on,
0:21:48do everything you want inside your intranet with igloo.
0:21:51Break away from the intranet that you hate.
0:21:53Go sign up for igloo right now
0:21:54and you can try it for free for any team
0:21:56with up to 10 people for as long as you want.
0:21:58Sign up at igloosoftware.com/radar.
0:22:02Once again, that's igloosoftware.com/radar.
0:22:04Start your free trial today.
0:22:05Thank you so much to igloo for supporting
0:22:07Under the Radar and all of Relay FM.
0:22:10- Okay, so once you now have the server set up,
0:22:14it's running, your system's up and going,
0:22:17the thing that of course seems worth pointing out
0:22:19is some of the lessons we've learned
0:22:21about how things typically go wrong
0:22:24when they actually, you know,
0:22:26so if you got this deployed, you got it running,
0:22:28hopefully you have something running to monitor it.
0:22:31I think I use Pingdom, I don't know what you use, but you have some kind of call where
0:22:35I also use Pingdom.
0:22:36There you go, they're a great service.
0:22:38You give them a URL and they will hit it.
0:22:41And one thing I always like with those kinds of URLs is don't point it to the root URL
0:22:47of your site to make sure that it's up.
0:22:50Have a special URL that it hits that will test your whole stack.
0:22:54So it will go down to the database, make sure the database is running.
0:22:57If you have a search query system, it'll go and hit that, and then report back results
0:23:03so that you're actually testing your whole thing.
0:23:05But you have something that's testing it.
0:23:08Every now and then you'll get a little message that says, "Oh, it's down.
0:23:12Why is that?"
0:23:14And usually, on the nice thing, it doesn't actually happen very often.
0:23:18For running as many services, I think we both run.
0:23:20Outages are pretty rare, things are pretty reliable and stable these days in general.
0:23:25and then you'll hit some kind of network outage in the data center, which you can't really
0:23:29do anything about.
0:23:30Which is awesome, because you can't do anything about it.
0:23:32Yeah.
0:23:33You know, you go on Twitter and you apologize to your users, and you just wait for the host
0:23:37to fix it.
0:23:38Yeah.
0:23:39And that's great.
0:23:40It's, it's, there's nothing to be done.
0:23:41And that's going to happen no matter where you are, too.
0:23:43Like, originally I'd think, oh, well, you know, maybe I, if I was using something else,
0:23:47I wouldn't have this problem.
0:23:48But it's like, everything has this problem.
0:23:51Like,
0:23:52I've been on a lot of hosts before.
0:23:53they've all had outages.
0:23:55>> Yeah, those are just built into it.
0:23:58But beyond that, there's not that many of things that happen.
0:24:01Usually the issues I run into, the most common thing that I'll hit is something like a machine
0:24:08will run out of disk space, which seems kind of basic, but it's happened to me several
0:24:11times where it turns out I have some log file that isn't being rotated correctly, and it's
0:24:18just like my machine is completely out of space.
0:24:20And so something—it'll just start falling over in a really confusing way.
0:24:24So I just go and check on my servers every now and then, and just make sure that they
0:24:29have space and the space isn't getting smaller and smaller, because most servers should just
0:24:32be very stable and unchanging.
0:24:35And once you do that, things are pretty good.
0:24:37And then you run into, unfortunately, the next most likely case of problems is probably
0:24:44what we would call human error.
0:24:46And unfortunately, you are the human that is causing the error.
0:24:51So when you're administering your own servers, you have all these little opportunities for
0:24:56you to do something that ends up breaking your backend.
0:25:00I've run a deployment to my RSS syncing system, Feed Wrangler, where I rolled a deployment
0:25:06out that dropped the main feed item table accidentally.
0:25:11That was an interesting test of how good my backup strategy was.
0:25:16and took the service down for four hours,
0:25:18but that's why you have backups,
0:25:20and that's why you eventually learn
0:25:23to be very, very, very careful
0:25:25whenever you're touching your production databases.
0:25:28- Yes, and yeah, database backup is very, very important.
0:25:32Every VPS provider I know of
0:25:34supports snapshotting the machine's backup.
0:25:36Usually you have to do something special
0:25:38to back up a database,
0:25:39because you can't just copy the file
0:25:41and have it be consistent,
0:25:42but there are tools for every popular database
0:25:44take snapshot backups of them and dump them into files or whatever. So look into that
0:25:48for your database of choice. For MySQL, it's definitely Extra Backup is the one I recommend
0:25:53from Percona. Postgres probably—you Postgres people, you're probably like, "Oh, well,
0:25:57it just automatically does this for you. You don't have to even think about it because
0:25:59Postgres is amazing, and MySQL is bad." Is that roughly correct?
0:26:04Not exactly. I use a thing called Wall-E as my backup system, which is—yeah, the nice
0:26:11thing about the most good backup systems too with databases is they can often allow you
0:26:16to do point-in-time recovery, which is really helpful for that kind of a human error problem,
0:26:23where you issued a particular command at a particular time and that destroyed all your
0:26:28data. So even if you had your backup, if you had a snapshot right afterwards, it's not
0:26:34like you need to recreate the database. You need to go back in time and undo queries.
0:26:38And so if you have a system where that uses point-in-time recovery, which I know Wally
0:26:43does and I'm sure there's MySQL things that do the same thing, you can kind of replay
0:26:47what your database was doing and recreate it just before you were an idiot.
0:26:51>> WESLEY CHUNG: Binary logging in MySQL.
0:26:52>> STEVEN SCOTT: Yeah, which is awesome.
0:26:53Being able to do that is a tremendously helpful thing.
0:26:57Hopefully you never use it, but I think given that we've both done it or done things like
0:27:02that, it will probably happen at some point and you just want to be prepared.
0:27:05>> WESLEY CHUNG; Oh, yeah.
0:27:06One thing also, earlier we talked about automating as much as possible with the setup. As much
0:27:11as you can, automate the health of your servers. Pingdom monitoring for the overall uptime
0:27:18of your app is great. One thing I do to prevent your disk space issue is I have two Pingdom
0:27:23alerts for any service I run. One of them is, is it up? And that one's on high alert.
0:27:27If anything goes down, like the main site is down, then everything of mine beeps and
0:27:34vibrates, like everything alerts me. But I also have a lower class one, usually called
0:27:39stats or vitals, where that hits a special URL which checks all the servers for things
0:27:45like low disk space and very high CPU load and things like that. And it gives Pingdom
0:27:51a down result if anything like that is out of whack and then it's logged in a place
0:27:57that I can see like what caused this. So I can see, oh, at noon every day this server
0:28:02has a really high load, or I can see,
0:28:05oh, this server right here has low disk space right now.
0:28:07So I'm never surprised by things like low disk space
0:28:11or very high load, because I have that automated
0:28:13and being automatically checked by another pingdom check.
0:28:16- Yeah, that's a great idea.
0:28:17Like, it's those types of things that you're just trying
0:28:20to think of ways to anticipate the problem
0:28:23before it happens.
0:28:24- Yeah, I mean, even like a low-tech version of that,
0:28:26which I've done on some servers,
0:28:27is you just put a cron job that runs every five minutes
0:28:30that emails you if disk space is too low.
0:28:32Worst case scenario, you wake up to a pile of 40 emails,
0:28:35okay, you go and fix it.
0:28:37So it's, yeah, it's great.
0:28:38There's so many easy ways to do this kind of automated
0:28:41maintenance of servers now.
0:28:43Running a server is really not as hard as you might think
0:28:47if you've never done it before.
0:28:48- Yeah, and I really think that if you can't,
0:28:51if the things that we're talking about this week
0:28:53sound scary, that's an important thing to get over
0:28:55and get used to and comfortable with.
0:28:58because as a developer, it feels like it's in some ways a very basic skill that if you
0:29:04can't do, you're kind of holding both your work back in terms of the level of complexity
0:29:12of the projects you can take on, as well as your career in terms of the things that you're
0:29:17able to do and the jobs that you could potentially get and those kinds of things.
0:29:22These are useful skills that don't go out of date.
0:29:24If you know at a basic level how to administer a server, that's always going to be useful
0:29:29and interesting.
0:29:30I don't think that's going away.
0:29:31As much as new high-level abstractions and things appear, that's cool and all, but
0:29:36Unix has been around for a very long time for very good reasons.
0:29:39All right, we're out of time this week.
0:29:41We'll probably cover more of these topics in the future or expand on them, so keep listening
0:29:44if you want more of this or anything else for that matter, because we are great and
0:29:48you should keep listening to our show.
0:29:49Thanks a lot for listening, everybody, and we'll talk to you next week.
0:29:52Bye.