/ development

Running your own servers

The common wisdom, which Justin suggests, is to go directly to a highly abstracted, proprietary cloud service or a higher-level hosted back-end — the kind that are so high in the clouds that they call themselves “solutions”. But the “BaaS” landscape is still very unstable with frequent acquisitions and shutdowns likely, and hosting on VPS-plus-proprietary-services clouds like Amazon Web Services or higher-level services like Heroku or App Engine can get prohibitively expensive very quickly.1 Developers who build everything on these services by default would probably be shocked at how cheaply and easily they could run on dedicated servers or unmanaged VPSes.

Running your own servers really isn’t hard. Most developers reject the idea outright without even trying because it’s unfamiliar and intimidating. It’s considered an extreme, horrible, unfathomable situation that must be avoided at all costs, usually by people who have never tried it.

But that’s a fallacy. There’s a learning curve and necessary integration work for every back-end option, from iCloud and Dropbox to your own collocated servers. AWS, Azure, Heroku, App Engine, Parse, and similar services aren’t free, easy, or automatic. (Neither is “scaling” with them, regardless of what you’ve heard.) Hosted infrastructure is like sync: it has a minimum, unavoidable level of complexity to accommodate. You can’t just check a box or set a BOOL and have it all taken care of for you.

— Marco Arment on marco.org

I very much agree. At work, we deploy to bare metal hardware (mostly). We have automated deployment systems that run on git push. It works great. It did take some effort to get up and running but, it works better for our needs than anything else would.

My own projects, like this site, run on Mac Mini running on Ubuntu and hosted by Mac Mini Vault. Before that, I ran a number of VPSes on varying providers like Digital Ocean(affiliate link), Linode and Rackspace. VPSes are great to learn on. If you do happen to mess up, you can always throw it away and start from scratch. Its pretty forgiving. The one issue I have with VPSes is that their performance feels pretty inconsistent.

It does take some time to get everything up and running. Once its up and running, you don't have to do too much. You do need to keep the packages updated. You have to figure out how to do backups. Eventually, you have to deal with the logs building up or hard drives filling up. Its not set and forget but, I don't think any platform is really set and forget.

Eventually, you're going to run into issues with anything. When that happens, you'll want as much access to your servers as possible. Having set things up yourself, you'll have a pretty good idea on where to look to find the problem.

I do take issue with one thing that Marco says:

6. I also maintain a giant shell script that configures everything I need on a clean install of CentOS. Once you’re comfortable with the basics, I suggest doing this, as it makes it easier to set up new servers or switch hosts. Making such a script is much easier with VPSes, where you can start a new one, test it out, change it as needed, delete the instance, and try again on a clean one. Ideally, your servers should be disposable and easily recreated. The only backups you should need are your source code (which should include any required server-setup scripts) and your database’s data.

There is no reason to make this a shell script (The rest of this is great). There are a plethora of tools that are designed for this exact purpose: Ansible, Chef, Puppet, and Salt. I've used all of them except Salt. They are all good and all fit into their own niche.

  • Ansible is by far the quickest to get started.
  • Chef is best for extremely large deployments. It seems to be leading in Infrastructure as code space. It feels the most like programming.
  • Puppet seems to be about in between Ansible and Chef. It doesn't feel quite as much like programming as Chef does but it does seem to be quite a bit harder to get going with than Ansible. I found their getting started guide to be horrendous. Puppet is what we use at my day job.

If you are looking to get started with one of these, I'd recommend getting vagrant set up. It supports all of these configuration management tools and it will allow you to rapidly develop and test your scripts.