System Design Flashcards

(3 cards)

1
Q

What updates would you make to ensure a system can scale to over a million users?

A
  • Make microservices stateless; allows for Kubernetes to horizontally scale services;
  • User a load balancer (e.g. AWS ELB) to distribute traffic
  • Cache data using Redis to allow for quicker reads; avoid database lookup
  • Use CDN (e.g. AWS CloudFront) to store static cached content; geographically closer to user ; quicker load times
  • Optimise database; using read replicas; indexing to speed up read queries; sharding and partitioning (?);
  • Introduce message queues (AWS SQS, Kafka, RabbitMQ); allow background services to handle the jobs async
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How would you design an API to be resilient and reliable?

A
  • Assume failure is normal; due to network failures, depedency services going down
  • Introduce timeouts to avoid delayed downstream service calls from blocking threads
  • Add retries with exponential backoffs; primairly on idempotent operations
  • Add rate limits to limit or control the pace of how many requests a user (client) can make within a timeframe; protects its from overloads and malicious bots
  • Ensure to paginate large responses to avoid database timeouts and reduce memory pressures
  • Add additional measure to make it attack resiliant; via authentication (using JWTs) to control access; validating and sanitise request data to prevent malicious input such as SQL or script injections
  • Ensure there is observability & monitoring and visualising using Grafana, Datadog; track metics such as latency, traffic, errors, resource usage; helps to better understand, debug and improve the system.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

When would you choose SQL vs NoSQL?

A

SQL: Used when data storage needs to be strict, structured & consistent; helps to ensure the use of valid foreign keys, contraints (e.g unique, not null data); easily handles queries with more complex JOINS across different tables
NoSQL: Used when you need a more flexible schema; need fast write operations as they’re more relaxed on the constraints that SQL databases enforce.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly