Never assume things that were not explicitly stated.
Question 1:
URL Shortening :
Use cases:
1. Shortening: take a url and return a much shorter url
2. take a short url and redirect to original url
3. custom url
4. High availability of system
out of scope
4. ui vs api
5. Automatic removal
5. manual link removal
Constraints:---
1. amount of traffic(How many requests)
2. data (how many urls )
Step 2 :Abstract Design:
1. Application service layer(serves the requests)
*shortening service:(check if present in hash or not )
*Redirection service:
2.Data storage layer (keeps track of has=>url mappings)
* Act like a big hash table
hased_url=conert_to_base62md5(original+random number))(take
first 6 characters)
Step 3: Think about bottlenecks
*load balancer to handle requets
* distibute data across many machines
step4: Scalability
What you should expect from a web host:
* Encrypted stream
* block some ips
* storage they are providing
What are the types of webservers:
Vps vs shared webhost:
virtual private server(using hypervisors like docker they create
many containers , for each customer create a containerEx:
Godaddy)
Amazon web services is also a vps
Load balancer :
acts like a proxy server , backend servers can have a private ip and
load balancer can have a public ip (for security ).
how to implement it?
1.send to less busy server.(Any alternative?)
2. send the packet and response goes to lB and it returns to client
Or we can have dedicated servers(for images, videos , html pages
etc )
Or load balancer can return the ip address of the servers in a round
robin server(EX: BIND). Then how cookies and sessions are
maintained?(Adding items to your cart ) have a php server, image
server, video server. .But now php server is overloaded now ?( )or
we can have a big hard drive to store cookie and sesion id
What if load balancer breaksor comes down?
Raid ( dell, apple allow to use it) have identical harddrives ,when
os writes to one it will also write to the other .Now data is still alive
if one drive dies .(New Technology)
Implementation of Load Balancer:
LVS(Linux virtual server), HA Proxy (software), citrix (provides
hardware for load balancers).
Instead of having a harddrive of cookies we can set cookie
data to set to server id.
How amazon , google use docker :