

How Google taught me to cache and cash-in - helwr
http://highscalability.com/how-google-taught-me-cache-and-cash

======
jasonkester
One thing I'd add to that list to everybody who's site is not Google:

    
    
      - Don't add caching yet.
    

There is a lot of low-hanging fruit that you can improve in the "fewer
queries", "more efficient queries" and "more efficient rendering" areas that
you'll never get a chance to realize if your first step when load increases is
to cache the piss out of everything.

My preferred order of doing things:

    
    
      1. launch your site
      2. wait until it starts to bog under load
      3. optimize until it's fast again
      4. repeat 2&3 as many times as possible
      5. add caching
    

Do it that way and you'll buy yourself a lot more time before running into
(and possibly avoid altogether) the dreaded step nine:

    
    
      9. buy more servers

~~~
ejs
I read this a lot how people say caching should be a last resort, but it
really depends on what you are doing. Many times caching can be the easiest
thing to implement on certain things.

I have done sites that have a signup page that have a lot of dynamic
statistics on that page... I could have spent plenty of time optimizing the
calls, but it is far easier to just cache the whole thing, and it will be
faster. Clearing the cache is usually not nearly that bad either.

~~~
jasonkester
You're right that caching is the easiest thing. That's why people do it.

The problem is that they do it right away, and then eventually the things
slows down anyway, and then they're hosed. In the example you describe, the
hosing would be relatively minor, since you could hand-optimize the queries
and simply plug them back in. In the more common case of caching your 50-query
homepage, you might end up needing to buy more servers without ever realizing
that you could have gotten it down to one query.

So yeah, if you're confident that your signup page is never going to get the
sort of load that'll slow it down despite your caching then you're right,
you're all set.

~~~
natrius
You're not hosed when things slow down. It's easy to disable caching on a
development machine and identify the slowdowns.

------
atlbeer
When coding sites I always follow the design pattern of, how do I return this
HTTP request as fast as possible. That's my number one priority, get the HTTP
request back to the browser before doing anything else.

All other work to be done because of that request, that can be done in the
background, will be done in the background.

------
jordanlev
Can anyone explain what "don't try to enforce partial ordering simultaneously
with your updates" means?

------
callmeed
Can someone explain #14? Is it really the golden rule?

