System Design Flashcards
To understand the problem you need to do 2 things…
- Basic knowledge of the fundamentals of good software design. That is, efficiency in terms of reliability, scalability, maintainability, and cost.
- Communication skills that allow you to scope out the problem, collect feature and non-feature requirements, justify your choices, and pivot when necessary.
System design framework
- Define your problem space (5-10 minutes)
- Design your system at a high level (5-10 minutes)
- Deep-dive (10-15 minutes)
- Identify bottlenecks and scale (10-15 minutes)
Examples of non functional requirements
Speed, security, reliability considerations, maintainability and even cost.
ScREAM
Scalable, Reliable, Efficient, Available, Maintainable
Network Protocols
rules and standards for sending and receiving data over a physical infrastructure
TCIP/IP model has how many layers? What are they?
- The Network Access Layer or Link Layer - which represents a local network of machines; the “hardware” layer.
- The Internet Layer - which describes the much larger network of devices interconnected by IP addresses according to IP protocols (IPv4 or IPv6.)
- The Transport Layer - which includes protocols for sending and receiving data via packets, e.g. TCP and UDP.
- The Application Layer - which describes how data is sent to and from users over the internet, e.g. HTTP and HTTPS.
OSI Model/Open Systems Interface Model layers
- Physical Layer
- Data Link Layer
- Network Layer
- Transport Layer
- Session Layer
- Presentation Layer
- Application Layer
Load Balancers
type of server that distributes incoming web traffic across multiple backend servers. Load balancers are an important component of scalable Internet applications: they allow your application(s) to scale up or down with demand, achieve higher availability, and efficiently utilize server capacity
You should use a load balancer whenever you think the system you’re designing would benefit from increased capacity or redundancy. Often load balancers sit right between external traffic and the application servers.
CDN
a CDN can be thought of as a globally distributed group of servers that cache static assets for your origin server.
Push CDN - devs manually push new assets to cdn server
pros - server stays up to date,
cons- time consuming for devs
Pull CDN - cdn caches assets, if it doesn’t have it then it fetches from origin
pros - easy to maintain, automatically fetches new assets
cons - assets can become stale
Good for reducing latency and serving STATIC assets to many distributed clients
CAP stands for
“Consistency”, “Availability”, and “Partition tolerance”.
Partition tolerance means
being able to keep the nodes in a distributed database running even when there are network partitions
network partition
a (temporary) network failure between nodes
Consistency vs Availability
Consistency is the property that after a write is sent to a database, all read requests sent to any node should return that updated data. In the example scenario where there is a network partition, nodes would reject any write requests sent to them. This would ensure that the state of the data on the two nodes are the same
In a database that prioritizes availability, it’s OK to have inconsistent data across the nodes, where one node may contain stale data and another has the most updated data. Availability means that we prioritize nodes to successfully complete requests sent to them. Available databases also tend to have eventual consistency, which means that after some undetermined amount of time when the network partition is resolved, eventually, all nodes will sync with each other to have the same, updated data.
When should Consistency or Availability be prioritized?
If you’re working with data that you know needs to be up-to-date, then it may be better to store it in a database that prioritizes consistency over availability. On the other hand, if it’s fine that the queried data can be slightly out-of-date, then storing it in an available database may be the better choice.
Why We Need Caching
Caches take advantage of a principle called locality to store data closer to where it is likely to be needed.
In large-scale Internet applications, caching can similarly make data retrieval more efficient by reducing repeated calculations, database queries, or requests to other services.