Basecamp is a very popular project management app. It is also blazing fast. How do they manage to do that ?
How fast do they get ?
If actions still take 500ms to render, it’s not going to have that ultra snappy feel that Basecamp Next does. To get that sensation, your requests need to take less than 100ms. Once our caches are warm, many of our requests take less than 50ms and some even less than 20ms.
Well, they love to share, so they did a post on how they built Basecamp Next and its speed sauce in How Basecamp Next got to be so damn fast without using much client-side UI. Here is what I think of their approach…
Basecamp is build on Ruby, but the concept they described is applicable to other language, including PHP, my expertise. Their speed lies in cache, or rather, their application of the cache concept.
You see, everything is cached. Their engine is build around using cache.
First, instead of communicating through JSON, they actually communicate real HTML file.
Second, they minimize HTTP request by keeping the layout the same between requests.
Third, they manage to get cache down to the atomic level. So, when data changes, they simply change the related cache. Which is one out of all elements displayed on the page. So, instead of creating a one page cache, they are creating element based cache. So a change in one element, only affect that element. They update that element cache accordingly.
Fourth, they share the cache with multiple users. This allows the cache to be reused again and again. Since cache is basically a simple html page, it is simply transported across with no processing done on it.
An important ingredient in the caching to the max recipe is sharing caches between users. When cache keys are free of user-specific attributes, requests are far more likely to hit a warm cache and remain snappy.
They have done a marvelous job on creating a high speed website. I suppose it is time for me to update my maximum load time from 1 seconds to 100ms and see if I can match their speed. What about you ?