Performance and Scalability
Performance and scalability is often overlooked and/or not thought about until your application falls on its face. No one likes going through that... I never want to do it again...
Cloud hosting helps but is not the end all be all to performance and scalability. Performance needs to be addressed from the start of the project and baked into the architecture. Cloud computing and CDNs can help you scale your application but the architecture should be sound with or without these services.
So what do you need to think about and do to ensure you don’t end up with egg on your face? Let's dive in.
Database/Object caching on the server side can prevent repetitive routines and queries across systems. This can greatly improve backend processing performance and speed of the overall application. (Best used when accessing data common to a large set of users.)
Output caching is super powerful as it basically takes a snapshot of the rendered page and serves that to users until the cache expires. These days we can use JavaScript and REST endpoints to workaround many of the restrictions we used to face with output caching. (Best used when delivering content that doesn’t change frequently.)
Browser caching via the expires header is also very powerful as it eliminates HTTP requests until the expires date has passed. Be careful with this as your users browsers wont get the latest version of the file until their expires date passes. Thus the HTML source page should usually not set an expires header. As a workaround you can change the file name and update your code so it forces a new download.
Distributed Caching is a must in distributed environments (load-balanced, cloud). Software such as Memcached will make this easy. A system such as this will allow multiple CPUs to share cache data preventing duplicate work and synching issues.
One of my favorite books on this topic is "High Performance Websites" from O'Riley (http://shop.oreilly.com/product/9780596529307.do?green=7BE80B82-62E7-5861-AB4A-91C967054FAA&intcmp=af-mybuy-9780596529307.IP). It's a great resource to have at your desk for quick reference.
Reducing the number of HTTP requests will significantly help improve the speed of your applications. There are several ways to do this and tools such as GRUNT and SASS can greatly simplify this process.
* Combine CSS files
* Combine JS files
* Use CSS Sprites
Delay HTTP requests when possible. If content is length wait until a user start scrolling to load it. If you have a UI element that only reveals pieces of content at a time; such as a, carousel, tab switcher or accordion, delay loading the content/images for those items until necessary. Also don't leave blank space on your page that makes it look broken, show a placeholder or loading graphic.
Enable file compression to reduce packet sizes when transporting data across the internet. Enabling Gzip on a server is quick and the benefits are great.
Put scripts at the bottom of your page when possible. Some scripts must run first but browsers currently stop all other requests from processing when loading a script as it knows there may be routines in that script that affect the page load/rendering.
Avoiding redirects seems like a no brainer but I have seen more than a few websites that redirect here, then there, then there and finally land you on the page. Its just rude.
Once you have a solid application architecture you can snap in cloud services and CDNs to help your application scale.
3. Hardware Optimizations
Cloud Services
Azure and AWS are the big players. I have worked with both and they have their each have their own pluses and minuses. From an architecture standpoint I like Azure, their services focus on specific tasks allowing the processes to be streamlined (e.g. web sites and table storage services). AWS is a bit easier to work with coming from a traditional hosting environment. Regardless of the service used plan your application architecture to take advantage of cloud services early. There are tweaks to standard architecture and considerations that need to be made when deploying to a cloud environment (same as a load balanced environment) that if not considered early can be a pain to setup later.
CDNs
Leverage a CDN such as Akamai, AWS S3 or Azure Blob Storage to geographically distribute your assets closer to your users and take load off your origin server (freeing it up to process requests more quickly).
Test your applications performance. You don’t have to invest millions load testing your application but do some load testing to know where you stand. Use load testing to identify bottlenecks so you know what to watch for and understand how many users your application can support. Record your results so you have a baseline to reference in the future.
Lastly monitor your application on an on going basis. There is nothing worse than getting a call that your application is down. Tools such as new relic can greatly ease the monitoring process and provide early notifications if there are problems.