Podcast Search

Developing Perspective

#112: Servers, Servers Everywhere.

Select a time to play from there. The line being spoken is highlighted as the audio plays.

0:00:00Hello and welcome to Developing Perspective.

0:00:02Developing Perspective is a podcast discussing news of note in iOS development, Apple, and

0:00:06the like.

0:00:07I'm your host, David Smith.

0:00:08I'm an independent iOS and Mac developer based in Herne, Virginia.

0:00:11This is show number 112, and today is Friday, March 8th, 2013.

0:00:16Developing Perspective is never longer than 15 minutes, so let's get started.

0:00:19All right, so today I'm going to be talking about servers.

0:00:23I'm going to be talking about the server infrastructure that I use, why I use it, and some of the

0:00:28lessons and things I've learned there. But before I get into my actual setup, I just

0:00:32want to respond to yesterday I mentioned online that I was, you know, going through this process

0:00:37of, you know, building up and establishing my server infrastructure for the my recipe

0:00:43book sync is infrastructure that I'm about getting ready to roll out in the next couple

0:00:48of weeks. I had a couple of questions like, Oh, how do you do that? Oh, what does that

0:00:51look like? And you know, make your blog post. And I just wanted to say, and sort of explain

0:00:57why I never blog about that kind of thing, or why I never put out the exact details of

0:01:01exactly how I do it. And the simplest version of that is that anytime you do anything that

0:01:07is a specific prescriptive sort of how to, something technologically based, the moment

0:01:12you hit publish, it's already out of date. It's already got all kinds, you know, things

0:01:17are just always changing. There's, you know, there's lots of components, there's lots of

0:01:19things going into it. And then every time you publish it, it's just going to keep getting

0:01:23more and more out of date. And that's the first part. And then the second part is that

0:01:30everybody's needs are slightly different. And as a result, there's always these little

0:01:34nuances and tweaks and changes and things that people will do that then cause problems

0:01:38or incompatibilities or questions that, you know, the logical thing is if I'm putting

0:01:42out a guide and saying, Hey, this is a way to do something, that there's a certain implied

0:01:47warranty that I'm doing with that and a certain obligation, not strictly, but an implied obligation

0:01:53that I would help people who sort of navigate that process.

0:01:56And that's just a tremendous amount of load and complication

0:01:58that just isn't something that I can take on.

0:02:01So that's why I never kind of really get into the weeds of how I do things

0:02:03technically.

0:02:05Similarly to why I don't publish a lot of coding how-tos or things,

0:02:08because the problem is if you put that out there and you say,

0:02:11hey, this is a cool thing that I did to learn whatever, now all of a sudden

0:02:16there's a lot of weight that gets carried along with that.

0:02:20Rather than talking at a high level-- and this

0:02:21is what I love about doing a podcast, is I can talk at a high level about something,

0:02:25give you pointers, give you direction, and hopefully that's helpful. And then, you

0:02:30can go in your own direction and sort of be more self-sufficient in that way.

0:02:33I don't know if there's an exception for something like an open source project or something

0:02:37where there's a bit more stability about it, but just for something like lightweight,

0:02:41this is how I do it, it doesn't work quite as well. The line of things, I did want to

0:02:47mention something that I've had a lot of people talk, "Oh, I'm a bit nervous getting

0:02:50into the server side, I don't know exactly what to do, you know, can make and rec making

0:02:54recommendations. And a timely one is RailsCasts, which is by Ryan Bates. And it is a amazing

0:03:02resource. It's basically a series of screencast tutorials about rails. And obviously, if you're

0:03:07not interested in Ruby and rails kind of thing, it may not be your quite your cup of tea.

0:03:10But if you've ever wanted to get into that kind of thing, it is he is very clear, he's

0:03:14very straightforward. And he's just a legend. Like I mean, he is very good at explaining

0:03:19something in a way that makes a lot of sense. There's a lot of kind of how to's in there,

0:03:24that he has the benefit of I being that's what his profession is. So he has the ability

0:03:27to go back and revise and update them. And there's also a comment section attached to

0:03:32each of his tutorials, which often has a lot of great feedback where if someone has a problem

0:03:36and then finds a solution, they'll often post it into the comments. And so often, you know,

0:03:40I'm working on a particular infrastructure or something. If I go into the comments about

0:03:44the place that sort of sourced the idea, there's almost always a solution to the problem that

0:03:48I'm running into, which is great. And I highly recommend that they'll be only in the show notes,

0:03:52but it's just real rails cast calm. And that's actually where I got the idea for what I'm going

0:03:57to talk about for the rest of the show, which is kind of how, where I've been heading in terms of

0:04:02setting up for server infrastructure and how I manage that. So right now, and this is just sort

0:04:08of the way what I feel comfortable with, it doesn't work for everybody. There's a lot of different

0:04:12options and a lot of choices. But right now I do almost all my hosting on Linode, which is a

0:04:16virtual private server provider, they do basically your leasing

0:04:20virtual Linux boxes by the, I don't even know, they price

0:04:25monthly, but you can come in and out of however you want.

0:04:27Basically, you know, means that I have virtual servers that are,

0:04:32in my experience, very, very reliable and very performant, or

0:04:35is performing enough for what I want. And are just kind of work

0:04:39work really well, they've actually been doing some recent

0:04:41updates and making even better and make their pricing even more

0:04:44competitive.

0:04:45That's kind of how I do it.

0:04:46And a typical sort of setup that I have for them

0:04:49is that I have an application load balancer in the front,

0:04:53which Linode provides a service called Node Balancer, which

0:04:55is just a $20 a month add-on that you can put in front

0:04:59of your boxes that will do load balancing for you, which

0:05:03is nice and convenient.

0:05:04And in my experience, it's been working really well.

0:05:07Behind that, I put a series of web servers running.

0:05:11Right now, I'm running Nginx and Unicorn,

0:05:14which is kind of my front end and Rails processor, whatever

0:05:18you call it.

0:05:19And then in the back, I have a database,

0:05:22which is right now Postgres or whatever you want to call it,

0:05:26running in the back.

0:05:27And so that's very straightforward, classic web

0:05:31hierarchy.

0:05:32A load balancer in the front, you kind of have that diamond.

0:05:34The load balancer in the front stands out

0:05:36to end web services based on the load,

0:05:40and then come down again into the database in the back.

0:05:43And the reason I use that infrastructure on Linode is it's very, very cost effective.

0:05:50And for the kind of load that I'm trying to manage, it works out to be very, very, very

0:05:54cost effective in that something like Heroku or one of the other kind of more elastic providers

0:06:01where there's an expectation of that you can sort of go easily and to some degree you can

0:06:05kind of turn up the scale yourself, that works well if that's something that you're really

0:06:10worried about. If you're really worried about sort of whatever the hockey stick turn on

0:06:15your app or your service, where all of a sudden you're going to need to be handling 100,000

0:06:20times more users than you did the day before, that potentially is useful. The nature of

0:06:25what I do, all the people who use my web sources for the most part have already given me some

0:06:29amount of money. And so that limits dramatically the growth that I can have. In kind of a weird

0:06:36way, that's a good thing, that there's a limit to the number of people in the world who are

0:06:39willing to give me a dollar every day. And so I don't have

0:06:42to worry too much about these kind of crazy spikes in growth.

0:06:46That being said, you want to have an infrastructure and a

0:06:49setup in place that allows you to scale as you need to. And

0:06:53this infrastructure is fairly flexible for that. And this is

0:06:56something that I'm going to be talking for the last latter part

0:06:59of the thing is you need to get very good at the provisioning

0:07:02process for new servers and to be able to grow and collapse

0:07:05your your needs as you as they as they sort of change. And it's something that you get

0:07:10very good at. And that's kind of the process that I've been working on. And this is all

0:07:14actually got started from there's a rails cast called Capistrano recipes, which I'll

0:07:19have links from the show notes, where Ryan talked about how he does does this and it

0:07:23was something that once I saw was just, you know, an answer to exactly what I've been

0:07:27looking for. And basically, all you do is you have a series of scripts for provisioning

0:07:32a fresh Linux installation to exactly what you want.

0:07:35You can do this with Chef, Puppet,

0:07:37there's all kinds of other variations on that

0:07:40that people use.

0:07:41But for someone like me who's not a system administrator, who

0:07:43doesn't do a lot of this, most of what I do

0:07:46is I set up a basic infrastructure.

0:07:48I put it out there and just kind of run

0:07:50Linux on for a while.

0:07:52That works fine.

0:07:53And I'm talking about systems with not crazy numbers of users

0:07:58because then you have numbers of users that are measured

0:08:00you know, for some of the apps it's hundreds of thousands, for some of the others it's

0:08:03tens of thousands, but you're, you know, that kind of load, I'm not going to go crazy in

0:08:09terms of building these super scalable infrastructures. I want something very pragmatic, very simple,

0:08:14and very repeatable for myself. And so this is what I've been doing for the last couple

0:08:18of days is I've gotten, I've been sitting there actually just consciously practicing

0:08:23tearing down and rebuilding servers over and over again. And this is, this is sort of the

0:08:27The lesson, the takeaway for today that I wanted to mention, is that you want to be

0:08:31able, before you ever launch something, you want to practice the worst case.

0:08:36You want to practice and get good at what the bad case for that could be.

0:08:41And so in this case, it's what happens if something goes bad with one of my machines?

0:08:45One of my things gets hacked.

0:08:46One of my, the machines that I'm physically running on has a problem.

0:08:50I need to spin something up new.

0:08:52don't want to learn the process of how to deal with that at that time. You want to be

0:08:59practiced and skilled in doing that ahead of time. And so what I spent all of basically

0:09:03yesterday doing is I just went into Linode and I'd say like, you know, rebuild this machine,

0:09:07fresh install, go through and run the, you know, work through my workflow for setting

0:09:12it up and getting it provisioned. And I got to a point where it's basically, you know,

0:09:17from start to finish, from an absolute, from an empty machine to a running web server,

0:09:21which is the one that I focus on mostly, is about 10 minutes for me. And most of that

0:09:25time is just watching, you know, scripts fly by and doing things. But that process and

0:09:30being very, you know, confident in that is something that gives me allows me to use something

0:09:34like Linode. If that's something that's scary to you, you may need to use something that's

0:09:38more managed, something that's more like a Heroku where they're doing most of that for

0:09:42you. And understanding that you're at a as a result, you're paying for that you're paying

0:09:47for that extra hand-holding and abilities

0:09:51that they're kind of laying on top of your infrastructure.

0:09:55So that's kind of what I do.

0:09:57And you can apply it to a lot of things.

0:09:58You also want to play around with load testing.

0:10:01A great tool for that is something

0:10:03called Apache Benchmark, or AB, you'll

0:10:05see it often called, which you can just get for any platform

0:10:09you can imagine.

0:10:09And it's just a really simple tool.

0:10:11All it does is you say, I want you

0:10:12to make 1,000 web requests, or I want

0:10:14to make you 10,000 web requests with a certain amount

0:10:17of concurrency. So I want you to make a thousand web requests, ten at a time. It lets you kind

0:10:23of see how your web service responds to that. And lets you kind of ramp up the volume in

0:10:28a way that is often a bit tricky to do otherwise. And it works really well. It's something that

0:10:32helps me kind of identify little bottlenecks or little issues in my web servers in a way

0:10:37that would be trickier to do without actual load. Obviously, once you have real users,

0:10:41using a tool like that is a little funny because you don't necessarily, you can only do it

0:10:44for a new infrastructure, you wouldn't want to put undo load on your, you know, your production

0:10:49environment when users are actually using it. But that's, it's kind of a strange topic

0:10:54for today. But I thought I wanted to kind of just work through kind of I get a lot of

0:10:57questions about how, how and why I want to use servers. And a lot of people get too wrapped

0:11:02up into all the, I don't even know, it's like a religious debate, but it's like a, there's

0:11:06a lot of different choices you can make. And at the end of the day, it doesn't really matter

0:11:11which infrastructure you use, if you're a PHP guy, if you're

0:11:14a Python guy, if you're a Ruby guy, if you're doing JSP or ASP

0:11:18or any of these infrastructures, at this point,

0:11:21and this point in kind of the maturity of web stacks,

0:11:26functionally, they're not going to make much difference.

0:11:28And I mean that mostly from like, your end user

0:11:31isn't going to notice a difference, really,

0:11:32if you're using one or the other.

0:11:34What's important to the user is reliability and stability

0:11:38and performance.

0:11:39And those things are something that is more on you for developing the skills that you

0:11:44need to manage whatever stack you're using and to understand the intricacies of it.

0:11:49I always find the thing that's dangerous with a tool like Heroku, which is great in that

0:11:55it's super easy and flexible, is that you can—it's a very leaky abstraction, maybe

0:12:01is the best way to say it, where it hides so much from you that you can start ignoring

0:12:08some of the complexity of what you're doing. And then at some point, the that complexity

0:12:13can sort of jump out and bite you in a way that you may not understand what's going on

0:12:18or may not know how to fix it, you'll have some strange conflict, or you'll have some

0:12:22weird caching thing that's going on that sort of at levels deeper than you can access levels

0:12:28that you're not really aware of. And that can be caused really weird problems. And that's

0:12:32something that may not happen every time it may not happen often, maybe won't happen at

0:12:36at all. But it's a danger that I love. For me, I like to have an infrastructure that

0:12:40I really understand that I know what's going on all the way from the, you know, from when

0:12:45the request is made all the way down to what OS that machine's running, all those kinds

0:12:49of things. That's why I use the infrastructure that I do. Learning Linux and learning to

0:12:55administer Linux, I think it's one of those skills. If you're, if you don't know how to

0:12:59do that, if you're not comfortable in a terminal SSHing into a machine, you really need to

0:13:04And I say that not necessarily as if you're a developer, you may never actually have a

0:13:10practical need to, but it's something that if you are uncomfortable with, you're probably

0:13:16missing out in terms of your ability to respond in a variety of circumstances.

0:13:22And it's not that hard at the end of the day.

0:13:24You know, it's like getting comfortable with all the various tools and what that looks

0:13:28like in a Linux machine.

0:13:29You can spin up one on Linode for $20 a month and play with it.

0:13:33Or there's even like Vagrant or Virtual PC or Parallels,

0:13:38I think can even just run a Linux server locally

0:13:40and you can just play with it.

0:13:42And I think it's just something that I would encourage

0:13:43a lot of you to do,

0:13:45'cause I think you're a better developer

0:13:46the deeper into the stack you have knowledge,

0:13:49whether or not you end up needing to use that knowledge.

0:13:52And basically, yeah, so that's how I do it.

0:13:54That's something that I'm looking forward to rolling out

0:13:56and I think it's a good exercise to go through

0:14:00and it's something that you,

0:14:02Even if you only are focused on the front end, understanding how back ends work is useful.

0:14:06All right, that's it for today's show.

0:14:08As always, if you have questions, comments, concerns, or complaints, I'm on Twitter @_davidsmith.

0:14:12I'm on AppNet @davidsmith.

0:14:16And if you're going to email me, if you have a question about the show, something like

0:14:19that, I'm david@developingperspective.com.

0:14:20All right, hope you have a great weekend.

0:14:23Happy coding, and I'll talk to you next week.