John Patrick Amata
← Back to blog

System Design 1: Essentials

My notes from studying systems design

system-design

I will be continuously updating this and adding sections over the next month

1. Scope of Designing Systems

3 layers

  1. Architectural: how are macro components are designed
  2. Logical: business logic, abstractions, algorithmic design, extensibility
  3. Physical: storage, IOPS, RAM, CPU, backups/restore, scaling policies

2. Mindset

2.1. Extensibility

About making it easy to create changes in your system. Is your low level implementation abstracted enough that the time to migrate to a new system is short? Payment gateway (e.g. Stripe) that your company is using is a good example. If your business pivots to a new area, how hard would it be to change layers in your software to accomodate it? How easy would it be to change your database from SQL to NoSQL? Are your services functioning like an independent business logic/domain like a microservice? How easy is it to break components in your codebase?

2.2. Business reality > engineering

Business prioritizes execution. You wont always have the time to do fancy optimization things to make the best software system like writing mutexes and playing with lock free algorithms, and its absolutely fine to write some spaghetti code when you donthave the luxury of time. Your job exists because of the business.

2.3. Cloud Architecture

Think about input and output, interfaces, storage (how would you store it), configure IOPS/how high. Over provisioned infra costs money and under provisioned could have a bad performance for the user. Capacity planning, how many servers to run, define autoscaling policies. Make design decisions based on response time, incoming traffic and expected response.

2.4. What to define

things that need to be defined

  1. Scope
  2. Think about the most important.

  3. Functional Requirements
  4. This is basically about the features for the user

  5. Non-functional requirements
  6. The engineering side of things, its basically how the sytem shoukld be implemented, like how should it scale and security.

  7. Critical Questions
  8. By critical I am not talking about questions like "why X?" but questions that shape the direction of the project, such as challenging the product design

  9. Clarifications
  10. Because theres lots of ambiguity like technology choices, e.g. noSQL vs SQL

  11. Bottom up or incremental build?
  12. Bottom up is building a set of components together, typically common in larger companies where there is a need for scale immediately. Incremental meanwhile is building an MVP then keep incrementing to improve it.

3. Start small

  • What are the building blocks
  • Like does it have an auth service

  • Their relationships
  • Like if the auth

  • Communication layer
  • Like do the services communicate via HTTP or a shared DB

  • What are their botlenecks
  • Like do I need to switch to NoSQL for X purpose

4. Analysing Systems

Each of these dimensions defines how a system performs and scales, thusthey become important to analyze

  1. Database
  2. The persistent layer, cos you'll need somewhere to store the data

    1. in-memory: usually caches
    2. blob storage: amazon s3, data is a binary long object, retrieved by key/path
    3. flat file storage: sort of blob storage but you can query them
    4. server database: MySQL servers
    5. embedded: DBs that run in the same app
    6. row based
    7. columnar
    8. disk based
    9. graphDB: to model graph relationships
    10. time-series: x-axis is time, y-axis is a metric
    11. relational DB: SQL
    12. non-relational DB: noSQL
  3. Caching
  4. Scaling
  5. Horizontal/Vertical

  6. Delegation
  7. Basically about how you delegate work, the most underrated way to squeeze more performance for a system

  8. Concurrency
  9. How to handle many concurrent users

  10. Communication
  11. GRPC system? Raw TCP? UDP?

5. Basics

6. Databases

7. Caching

8. Async

9. Resiliency

10. Scaling