Neetcode System Design Concepts Flashcards
How can we vertically scale a single server?
Give it more RAM or CPU (memory or raw computing power)
Why is vertically scaling a server limited?
You’ll run out of computing power fast. Won’t be able to keep up with compute demands
Why is vertically scaling a single server risky?
It creates a single point of failure if anything happens to that server. All our eggs are in one basket
What is the advantage of horizontal scaling vs. vertical scaling?
Horizontal scaling allows us to create replicas of a single server which eliminates our single point of failure problem and allows us to get a lot of computing done with average servers. Don’t need really high power servers to make this effective
True or False: Horizontal scaling can scale infinitely in theory
True
Does a horizontally scaled system have better availability than a vertically scaled one? Why or why not?
Yes - a horizontally scaled system allows us to eliminate the single point of failure issue and allows us to route traffic to different servers depending on the health of a server
What is a disadvantage to horizontally scaling servers?
It’s much more complicated than vertically scaling. You have to make sure one server doesn’t get overloaded or many servers don’t sit idle. You also have to use load balancers to balance out the load, etc.
What is another name for a load balancer?
Reverse-proxy
How does a load balancer work from a high-level?
It takes in incoming requests and redirects them to the correct server
What are two methods for redirecting traffic in a load balancer?
Round robin & hashing
Let’s say we have a global infrastructure, how can we use load balancers to our advantage from a geographic standpoint?
We can use load balancers to route traffic to the nearest location or region
If we have a global system, how can we deliver static content like images, HTML, CSS?
We can use content delivery networks (CDN). This allows us to configure how we deliver static content across our network
What is a content delivery network?
It’s a network of servers that are located all around the world. These servers can delivery static content like images, videos, HTML/CSS/JS
How do CDN’s take files from our server and put them onto the CDN?
It takes the file from our origin server and copies them onto CDN servers
True or False: CDN’s can copy data on both a push or pull basis
True - this can be done push or pull
What is a general definition of caching?
Creating copies of data so that it can be refetched faster in the future
What is the advantage of caching on a machine?
Things like network requests can be expensive time-wise (take a long time) so we can cache this data to disk to reduce that time burden
Is reading disk expensive?
Yes, we can copy to memory but that can be expensive too, so usually our operating systems will copy this into a subset of our CPU (L1, L2, L3 CPU cache)
What is an IP address?
Every computer is assigned an IP address, which is a unique identifier for any machine. You can think of this as the telephone number for any machine
What does the Internet Protocol Suite include?
IP/TCP & UDP
What is the purpose of TCP?
Sending data over a network has to have a set of rules, TCP enforces these rules
True or False: TCP can fail because it doesn’t resend a request that fails
False - TCP will automatically re-send any requests that fails
When you type in a URL, how does the computer know which IP address it belongs to?
DNS (domain name system) solves this. You create an “a” record that points a URL to an IP address of the server