Engage, Scale & Virtualize
A good friend of mine got chills everytime he heard the word Scale. WTF? In a sense, in just 1 word, it represents a very significant amount of time, thoughts, plans and most definitely efforts to enable any entity to expand and grow. That's why that particular word is accompanied by 2 other words that I'm sure will help a lot easing my friend's chills :)
The first word: Engage is the primary cause of the other 2 words. To scale and virtualize is the direct effect of it. Any website will want to engage their visitors and visitors to engage them right? Websites are more and more becoming a public service hosted and ran by private entities. Here in Indonesia with more than 15% of our population now online, it will take quite the effort to be able to engage that many visitors at any given time. The climate is favoring startups right now and it's great to be part of one.
I say this with confidence, you can ask any website, we must have some plans increasing engagement. From old school techniques be it ATL or BTL to a more current strategy of fishing visitors with social network campaigns. All of them works! If not for every website then for some websites. Come on, we can't burn money without hope right?
Just after mid 2010, a few weeks ago, we saw a TV ad of Koprol aired nation-wide. It boosted new user registrations very significantly I assume. Two weeks ago, Jakarta has around 18.000 people registered and while writing this blog post, now Jakarta is populated by 47.000 people. Organic growth can be predicted but with the kind of resource available for Koprol they must have scaled exponentially beforehand. By the way, cool 503 page man!
So what about the rest of us who are bound by the limitation of our own resources? How the heck do we scale? This can go all night! Both founders of Tokopedia, William and Leon told me their tricks while discussing the topic with Pak Andry Huzain of Detikcom. They scale by design which means that they are aware of the need of scaling right from the beginning. They separate their app and db servers and therefore enables them focus on each server's optimization.
For me personally, I'd rather use multiple boxes of unused desktop PCs in a app/db scheme but for the db server, give it a bigger chunk of the budget. Having multiple boxes, spreads the CPU load better when compared with only 1 big app server. It also offers redundancies and fail over capabilities when disaster happens. If the current number of boxes is not enough, you can always add more.
HAProxy will definitely be a useful load balancer. It's small and very flexible. During a lab test, HAProxy can withstand stress tests of over than 9 Mbps. The daemon didn't die even though it overused the max connection defined in its configuration. We needed to push the envelope further with speeds nearing Ethernet speed but for a website with an average bandwidth use of 2 Mbps, testing to 9 Mbps can gave us a preview of what kind of infrastructure needed to scale up. HAProxy can also act as a stable MySQL proxy since 1.4. This is very interesting, it basically cuts down the learning curve and therefore minimize misconfiguration cases.
Another option for load balancing HTTP/HTTPS servers will be pound. This is a definite keeper. I talked about bandwidth throughput with HAProxy in the last paragraph and just before continuing to write this blog post, I did a little comparison with pound. Straight out of the box without optimization, pound handled 12 Mbps without any worries :) The server with pound installed and all the app servers behind reacted gracefully with the stress test. I'm really impressed by pound's ease of use to be honest. It had only 10 lines of configurations compared with HAProxy's 43 lines.
The next on the list was of course security. I hate (D)DOS, it's a nuisance happening right when we're growing? That's why I must put more measures to fight against it. A few months ago, me and a friend gathered up a few desktop boxes and used PFSense to route and serve captive portals to users. While tweaking the installation, I was becoming more and more interested towards the BSD platform. My first experience with FreeBSD was scary :( but with PFSense, it's more humane to say the least. The best thing BSD platforms has to offer is the ability to limit connection rates. With Linux, there's no out-of-the-box solution ready so I went ahead with PFSense. You must have a go with it, it's quite the opposite with all your BSD experiences before I bet!
Earlier I mentioned that I was discussing scaling with the Tokopedia guys and Pak Andry. I asked to Pak Andry what kind of optimization is implemented by Detik. It's suffice to say that they are crazy :p I'm not sure if I can say too much but to give an overview, they are the very definition of "Living On The Edge". Everything is the latest and optimized by hand. They don't stop improvising! For a company already big and settled as one of the biggest in Indonesia, their approach to scaling up is the biggest compliment any startup can have :)
So what's next? I vote for Virtualization. Only recently I indulge myself in learning more about virtualization. Back in the days, when the technology is still young, I wouldn't even think about it. But now, I run Parallels in my Macbook and my Hackintosh. Virtualization has matured as a reliable alternative to mutiple boxes. So that's what I did! The platform of choice is Citrix XenServer. Free and part of it is Open Source. The free part is really amusing I must say. XenServer is included with a control panel software called Citrix XenCenter which runs only in Windows. Even with the free version, you are offerred with the ability to clone VMs BUT everything you do must be done when the VM state is offline. You must upgrade to a more advance version to get all the good stuffs. In some point, YES I will make the choice to upgrade but for now, this will do.
I haven't said the best thing I found about XenCenter which is the ability to template your App servers. So if any app server simply goes down because of attacks or any other cause, you can just make it offline and bring up a new app server from the template. With just a few configuration adjustment, the new app server will be up and running. The more hard drive space you have, the more flexible. That's why the next focus will definitely be building a Storage Area Network when it's time.
With all the goodies offered with zero cost at the beginning, these are the best things a startup can have. It's more appealing and cheaper to have an infrastructure up and running rapidly compared with a few years ago. So for startups, there's no reason infrastructure be a slow starter!