Marco Arment Uses Go Instead of PHP and Saves Money by Cutting the Number of Servers in Half
On the excellent Accidental Tech Podcast there's a running conversation about Marco Arment's (Tumblr, Instapaper) switch to Go, from a much loved PHP, to implement feed crawling for Overcast, his popular podcasting app for the iPhone.
In Episode 101 (at about 1:10) Marco said he halved the number of servers used for crawling feeds by switching to Go. The total savings was a few hundred dollars a month in server costs.
Why? Feed crawling requires lots of parallel networking requests and PHP is bad at that sort of thing, while Go is good at it.
Amazingly, Marco wrote an article on how much Overcast earned in 2014. It earned $164,000 after Apple's 30%, but before other expenses. At this revenue level the savings, while not huge in absolute terms given the traffic of some other products Marco has worked on, was a good return on programming effort.
How much effort? It took about two months to rewrite and debug the feed crawlers. In addition, lots of supporting infrastructure that tied into the crawling system had to be created, like the logging infrastructure, the infrastructure that says when a feed was last crawled, monitoring delays, knowing if there's queue congestion, and forcing a feed to be crawled immediately.
So while the development costs were high up front, as Overcast grows the savings will also grow over time as efficient code on fast servers can absorb more load without spinning up more servers.
Lots of good lessons here, especially for the lone developer:
Attack the hot spot. Go was not used for the entire project, much of which is still in PHP. Go was used to attack one hot spot, a major bottleneck that was a huge resource hog. As John Siracusa said on the show, "Put your effort towards the thing that gives you the biggest bang for the buck."
Polyglot programming. Marco is showing the pattern of specializing functions over time. First, make it work, then see what's happening, then make smart changes. Use PHP where it works best, use Go where it works best, and maybe in the future move to 3rd party products as scale, features and temperament dictate.
Keep an open mind. Marco thinks for most web app problems other languages aren't better enough at solving problems to make them worth learning when compared to PHP. Go is a different sort of language and it's good at parallelism and concurrency, which makes it a valuable tool to have your tool belt for certain kinds of problems.
Festoon your tool belt. Marco also talked about how there's a benefit to just learning another language. He now has a valuable tool in his tool belt for certain kinds of problems, that he knows and trusts well enough to use again.