Mad, Beautiful Ideas
Building Scalable Web Sites

ScalableWebsites.pngI had never planned to be a web-developer. I just sort of fell into it, which has worked out well overall, but I've had a rough time learning what is generally considered best practices in the industry. The first company I was working for had been built on virtually no infrastructure, by people whom I honestly feel knew a lot less than even I did. The application was poorly constructed, hard to reuse, and the servers configuration left a lot to be desired when our webmaster left, leaving me the sole IT staff of a company that wanted to be an eCommerce powerhouse. It was difficult to learn best practices, when the code-base which has been thrust upon you is in such a frightening state of disarray.

The code wasn't in source-control, edits were made against the production site. There were multiple copies of each include file, typically only one of which was actually in use. The code was the best example of PHP Spaghetti Code I had ever seen. Whenever anyone says that PHP is a terrible language, this was exactly the application they were talking about (it was closed source, so I'm being a bit facetious, but it was awful). For a lot of reasons I wasn't very disappointed when my life took me away from that place and into my current position. Sure the technology was classic ASP and VBScript, neither of which I knew, but the software was at least well designed. Within two weeks, I was contributing code changes, fixing bugs, and implementing features. Still no source control, but we're close to fixing that.

I knew I needed to know more. The problems that we typically face are rarely real scaling problems, we do things that work well for our relatively small data sets and relatively small user-bases, that I know wouldn't serve us forever if we expected real growth. But we're a niche internal service, and we've got plenty of room to grow for the time being. Still, I needed to know more, so I found this book, Building Scalable Web Sites by Flickr engineer Cal Henderson.

For those unfamiliar with Flickr, it's the photo sharing site that has over 4000 photos uploaded every minute as of this writing. It's enormous. Clearly, Cal and his team know a thing or two about scaling web applications to the massive scale. And it shows. This book is written very generally, talking more about things you should consider than actually walking through building an application, and it walks it's way through the stack from hardware to software to the NOC you host in. It's best piece of advice is simple: build the site you need right now, not the site you hope to be next year.

The book is a little older, having been published in 2006, but a lot has happened in the web space in the last two years. We've had the launch of Google's App Engine, Amazon's Elastic Compute Cloud, and Microsoft's Windows Azure, which will have an enormous impact on the Web Applications space, because now you can host applications that scale nearly infinitely without ever investing in hardware, but I still believe that applications can and will outgrow these services, and even the hardware considerations discussed by Henderson will be useful.

More than that, however, is the discussion of how to design the software. Henderson talks again and again about a layered approach to application design, whether it be the business logic to support multiple front-ends, the database caching system, or the server farm in general, Henderson does an excellent job of walking you through all the considerations you might need in order to build the infrastructure for a successful web application which can scale with your company. A lot of what Henderson has to say seems like common sense once you've read it, but most really good ideas do, in my experience.

I now understand why Remember the Milk practically lists this book as required reading for their job applicants, and I suspect a lot of others feel the same way. Even if you're planning on deploying to one of the newer cloud-services, you owe it to yourself to read this book. It won't guarantee you success, nothing can, but it will at least make sure you're as armed as you can be to enter the playing field on a fair level.