Scaling by Caching

Scalability Pattern: General Caching

Overview of caching

  • Save the result of a request with a given set of parameters.
  • In a future request with the same parameter (maybe) return the same result
  • System level caching. Storage:
    • In ‘local’ memory
    • In ‘remote’ memory
    • In database
    • In Cloud
  • Awareness of order of magnitude speed of operations:
    • Access registers inside CPU
    • Access CPU caches
    • Access standard RAM
    • Access local disk
      • Access files
      • Access local database
    • Access over network
      • To a nearby server
      • To a nearby database server
    • Access over the internet
      • To a remote server
      • To a remote database server
      • To a remote Web Service
  • Memoization:
    • caching applied to an individual method
    • A basic programming technique
    • Simple
  • Name-value databases
    • Very fast searches and lookups
    • Distributed searches and distributed databases
    • Robust across system and application failures
  • Database Caching
    • To a certaine extent, it’s what databases do
    • Caching both at the server (postgres itself)
    • And at the client (the postgres and activerecord subsystems)
    • Yet a lot more can be done
  • Server page caching
    • Done at the server
    • Don’t regenerate the page if it’s requested again
    • As long as you know it hasn’t changed
    • Page fragment caching, including “russian doll caching”
    • A key feature of good frameworks