Skip to content

Instantly share code, notes, and snippets.

@alex
Created May 2, 2015 17:25
Show Gist options
  • Save alex/4d95f6b522193350ada6 to your computer and use it in GitHub Desktop.
Save alex/4d95f6b522193350ada6 to your computer and use it in GitHub Desktop.

Tips for Scaling Web Apps

  • Magic numbers

    • 100ms ideal 50th percentile latency, 1 second 98th percentile solid
    • A medium sized physical box (8 cores, 24GB of RAM) should be able to do thousands of requests per second
  • Monitoring and metrics
  • Deployment strategies

    • Roll web nodes a few at a time, drain connections
    • Continuous deployment

      • Feature flags
      • Dark reads
    • Your application code should be able to handle DB in any relevant state:

      • Add new column to DB nullable
      • Deploy code to write values to it
      • Backfill values in an offline script
      • Verify integrity of all data
      • Deploy code to read from it
      • Remove other branches from code
  • Static assets

    • CDN
    • Immutable asset names
  • Sessions

    • Use authenticated (+ encrypted) cookies if at all possible
    • Fallback use a simple K/V store, best-effort persistence is fine (e.g. memcached)
  • Load balancer

    • Put your web nodes behind one from the start
    • Min-conn is a good distribution strategy
    • Health check every few seconds
  • Databases

    • For most applications a relational database is fine
    • Read replicas
    • Put analytics workloads on a different replica (WAL-E)
  • Caching

    • Use memcached for 99% of workloads
    • Use it judiciously, don't depend on it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment