I’m building a web app which will serve content to a constantly growing user base. I’m wondering where to start with scalability, and how to measure the performance of my app, so i know when it’s needed.
For example, I understand that as traffic to a site grows, things like minifying scripts and using caches for static content will help manage load times, but I’m not sure when the right time is to implement these features.
Additionally, how can I measure the performance of the site, to know when it’s time to start adding more servers,and building out the robustness of the app, etc – before my servers start crashing and choking?
Thanks in advance…
Start by defining a service level that you want to provide your users. For example, any page should never take more than 1 sec to load from a users perspective. The site should have 99.9% uptime, etc.
Based on the service level, define acceptable performance (in page load times, etc).
Benchmark existing performance. ie measure your current performance on different criteria at current usage level.
Identify pages that you want to optimize. If most of the site needs optimization, you want to look at overall solutions (eg: minifying js/css, caching, etc). If specific pages need optimization, look at individual queries, etc.
Measure performance periodically to see if your service level is still met or you need to scale further.
These are the general steps you can take. As far as specific steps, consider:
Partitioning/ splitting of everything (databases, multiple webservers, etc).
Asynchronous design (ie any process you thing can take a lot of resources, you should convert into an asynchronous process. Say you allow users to upload a document. The app then takes the doc. and does some processing on the doc. Instead of doing all the processing on the single php page, add the request to a queue, then let the user know immediately that his request is queued. Have a separate background process do the processing by looking at the queue. Once complete, you can let the user know that his request was processes.
For more guidelines, you may want to check out a book called “The art of Scalability” http://amzn.to/oSQGHb