Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

...

Algorithms Unlocked

  • Summary

    • 1. What Are Algorithms and Why Should You Care?

    • 2. How to Describe and Evaluate Computer Algorithms

    • 3. Algorithms for Sorting and Searching

    • 4. A Lower Bound for Sorting and How to Beat It

    • 5. Directed Acyclic Graphs

    • 6. Shortest Paths

    • 7. Algorithms on Strings

    • 8. Foundations of Cryptography

    • 9. Data Compression

    • 10. Hard? Problems

...

  • Key things I want to remember for the purposes of system design interviews:

    • Think about how you could break down an app into different services (e.g. login vs searching vs. completing a cart) hosted in different server pools, or how you could shard the data effectively (for example, maybe first by geography, then by user ID).

  • Summary / Notes

    1. Reduce the Equation

      1. Rule 1 - Don’t Overengineer the Solution

      2. Rule 2 - Design Scale into the Solution (D-I-D Process) - Design Design for 20x capacity, implement Implement for 3x capacity, deploy Deploy for ~1.5x capacity

      3. Rule 3 - Simplify the Solution 3 Times Over

      4. Rule 4 - Reduce DNS Lookups

      5. Rule 5 - Reduce Objects Where Possible

      6. Rule 6 - Use Homogenous Networks

    2. Distribute Your Work

      1. Rule 7 - Design to Clone Things (X Axis) - Be able to duplicate data/services

      2. Rule 8 - Design to Split Different Things (Y Axis) - You can split up your app / data / servers based on either actions the user/app can take (“services”) or by data the app may need to access (“resources”).

        1. Services examples - signup, login, search, browse, view, add-to-cart, purchase/buy - “The data needed to perform any one of these can vary from the data needed for the others”

        2. Resources examples - product catalog, product inventory, user account information, marketing information

      3. Rule 9 - Design to Split Similar Things (Z Axis) - Set data up into unique and separated shards or swimlanes - Separate the db / servers by things like customer ID, name, geography, etc.

    3. Design to Scale Out Horizontally

      1. Rule 10 - Design Your Solution to Scale Out--Not Just Up

      2. Rule 11 - Use Commodity Systems (Goldfish Not Thoroughbreds)

      3. Rule 12 - Scale Out Your Data Centers

      4. Rule 13 - Design to Leverage the Cloud

    4. Use the Right Tools

      1. Rule 14 - Use Databases Appropriately

      2. Rule 15 - Avoid Using Firewalls - Firewalls cause issues with scalability and availability, so only use them when they significantly reduce risk or are required for compliance.

      3. Rule 16 - Actively Use Log Files

    5. Don’t Duplicate Your Work

      1. Rule 17 - Don’t Check Your Work - Don’t read data you just wrote unless it’s a regulatory / legal requirement, and if so, consider doing it asynchronously.

      2. Rule 18 - Stop Redirecting Traffic

      3. Rule 19 - Relax Temporal Constraints - For example, requiring items being available from when a viewer views them until they purchase them.

    6. Use Caching Aggressively

      1. Rule 20 - Use CDNs

      2. Rule 21 - Use ‘Expires’ Headers

      3. Rule 22 - Cache Ajax Calls

      4. Rule 23 - Use Page Caches

      5. Rule 24 - Use Application Caches

      6. Rule 25 - Use Object Caches - These are used for data that may be expensive to regenerate, like the result set of complex db queries.

      7. Rule 26 - Put Object Caches on Their Own Servers

        1. They have a diagram of multiple web servers connecting to an application server object cache, which connects to multiple app servers, which connect to a db object cache, which connects to db servers.

        2. They use the word “tier” to refer to these servers being another entire row in their diagram.

    7. Learn from Your Mistakes

      1. Rule 27 - Learn Aggressively - Use A/B testing, postmortems.

      2. Rule 28 - Don’t Rely on QA to Find Mistakes

      3. Rule 29 - Failing to Design for Rollback Is Designing for Failure - Practice rolling back in staging or QA.

      4. Rule 30 - Discuss and Learn from Failures - Do postmortems

    8. Database Rules

      1. Rule 31 - Be Aware of Costly Relationships

      2. Rule 32 - Use the Right Type of Database Lock

      3. Rule 33 - Don’t Use Multiphase Commits

      4. Rule 34 - Try Not to Use “Select for Update”

      5. Rule 35 - Don’t Select Everything

    9. Design for Fault Tolerance and Graceful Failure

      1. Rule 36 - Design Using Fault Isolative “Swimlanes”

      2. Rule 37 - Never Trust Single Points of Failure - Identify single instances on design diagrams and try to turn them into active/active configurations.

      3. Rule 38 - Avoid Putting Systems in Series

      4. Rule 39 - Ensure You Can Wire On and Off Functions

    10. Avoid or Distribute State

      1. Rule 40 - Strive for Statelessness

      2. Rule 41 - Maintain Sessions in the Browser When Possible - Use cookies, this lets the user request be served by any web server in the pool.

      3. Rule 42 - Use a Distributed Cache for States

    11. Asynchronous Communication and Message Buses

      1. Rule 43 - Communicate Asynchronously As Much As Possible

      2. Rule 44 - Make Sure Your Message Bus Can Scale

      3. Rule 45 - Avoid Overcrowding Your Message Bus

    12. Miscellaneous Rules

      1. Rule 46 - Be Wary of Scaling Through Third Parties - Own your destiny, reduce your total cost of ownership.

      2. Rule 47 - Purge, Archive, and Cost-Justify Storage

      3. Rule 48 - Remove Business Intelligence from Transaction Processing

      4. Rule 49 - Design Your Application to Be Monitored

      5. Rule 50 - Be Competent

    13. Rule Review and Prioritization

...