Ask HN: My web startup is growing fast what next?
Our website is in beta phase and I am the only coder in the team. Looking at the idea some investors have given us a decent amount of money.
We launched this site through invitations to 100 people. Within a week we hit the 1000 registered users mark. Till then we had hosted our site on rackspace cloud with a server with 256MB (thats not a typo) machine. The tech stack was LAMP.
Sensing the growth we increased the RAM to 1 GB. The number of users at any given time was around 40. The RAM was more than sufficient for such a scenario but still the site started slowing down.
I immediately shifted the mysql server to a different machine. That really did not make much difference.
So I looked at the most frequently used operations (which was some queries with joins). I indexed all the tables accordingly and installed memcache to cache the queries for half an hour or so (wherever possible).
Now the number of online at any given time is increased to 120. Total registered users is 9000. Our investors are happy and co-founders think we are successful and now trying to buy an office for ourselves and build a proper team.
However I am clueless as to think how we can scale hence forth.
Can people give me some pointers as to the different paths I can follow? Please note that we cant host the server ourselves, we would love to continue with rack-space.
19 comments
[ 2.7 ms ] story [ 35.6 ms ] threadI second that, especially when you have moved mysql on a separate server. I'm sure you're missing something basic here (as happens to many from time to time :-)).
Feel free to email me, address in profile.
Robert Taylor Sr Systems Engineer (Linux) Rackspace Hosting robot@rackspace.com
This way, you will know for sure if you need another machine, more RAM, or just another table index.
1. Memory - very easy to scale up to a machine with more, maybe throw a Nginx frontend on it if you are getting too many connections 2. Bandwidth - move resources to a CDN assuming you already gzip and minify text, combine javascript files, and have appropriately sized photos. 3. Disk I/O - change DB structure again, more/better caching, set up load balancers (there are tons of other optimizations to do before you get to this point) 4. CPU - profile your PHP to see what takes so long. Flush your output as soon as possible so users see something faster.
Lastly be sure you have a redundant setup with auto-failover. 9000 users get very unhappy very quickly when you start having unexpected downtime more than 0 seconds.
1. Memory: We have 2 GB and "free -m" shows that more than 200MB (least) is free at any given time. Do I still need to add more memory?
2. Our site scores perfect A on Yslow. So minification , gzip, far future headers etc is in place.
3. We have improved out DB structure a lot. Since we are adding more features continuously we are constantly changing the DB structure. With the help of some more experienced programmers I will get these things tweaked. But in MySQL okay if our user base will hit 1 Lakh in next three months ?
4. CPU profiling is something that we haven't done yet. Will do this asap. Can you suggest some resources starting points ?
You also said something about load balancers. Will you please give me some resources to start up with ( I know I can google but ...) ?
5. Fail-over is something that I did not think of initially. What are the best tools around ?for the same ?
The whole discussion might sound as if I want you guys to spoon feed me. But that is not the case. Let us look at the whole questions as an opportunity to share each others views on the same topic, even the experts might get to learn new things.
I doubt if many here will understand what is 1 Lakh. Better make it 100,000. :-)
(BTW, where do you live?)
5. For a quick, easy, simple setup, assuming you're using Apache for your web server(s), setup another server running nginx and then use proxy_pass to load balance traffic between multiple web servers. Example: https://gist.github.com/2f4118028ed04c40862e
I suggest doing more reading on nginx load balancing and PHP xdebug profiling
We've repeatedly experienced huge performance gains even with basic/minor tweaks of my.cnf.
HTH
As you probably know, the default configs of both - mysql and apache are usually pretty minimalistic so tuning these in accordance with your load/traffic scenarios can pay you off big-time in terms of performance boost.
On that note, I'm sure they have some highly competent people out there at RackSpace who should also be able to help you out with all this.