Objectives
Learn to break down a very complex problem into smaller problems
Solve each smaller problem and bring them together to solve the larger problem
Learn how CDNs work and build your own CDN
Overview
In this project, you are going to build on the first and the second project. You will build your own “CDN load-balancer”. A cloud typically hosts multiple copies (replicas) of the same content. Depending on where the request is coming from, it routes the requests a suitable replica. A primary component of any CDN is the entity called a load-balancer. The function of a load-balancer is route requests to the “most suitable” server. CDNs choose their own metric for defining which server is the most suitable. It can be the replica with the lowest latency, the replica with lowest loss, or a combination of multiple parameters.
In this exercise, you will create three replicas with the same content. You will also keep track of the delay and loss parameters to each replica. At the beginning, each replica will download some content from a website. When a request comes in, you will redirect the request to the most suitable replica (see the definition below), download the content, and close the connection. When the next request comes in, you will redirect that request to the most suitable replica at that time. The network conditions will change throughout the experiment.
The client and server communications may use TCP or UDP.
$ replicaserver -p <PORT> -s <LOG FILE LOCATION> -p <web page to download>
1.PORT
- The port server listens on.
2.Log file location
- Where you will keep a record of actions.
3.p
- Which webpage to download and serve.
For example:
$ replicaserver -p 30000 -l /tmp/logfile -p www.nytimes.com
Functional requirements
Load Balancer Specifications
$ loadbalancer -s <SERVER-IP> -p <PORT> -l LOGFILE
The load balancer takes three arguments:
1.Server IPs
- A list of replica servers’ IP addresses
2.PORT
- The port the servers listen on. They will all listen to the same port
2.Log file location
- Where you will keep a record of packets you received.
For example:
$ loadbalancer -s replica_servers.txt -p 6543 -l LOGFILE
Client Specifications
$ anonclient -s <load-balancer-IP> -p <PORT> -l LOGFILE
The client takes three arguments:
1.load-balancer IP
- The IP address of the load-balancer.
2.PORT
- The port the server listens on.
2.Log file location
- Where you will keep a record of packets you received.
For example:
$ anonclient -s 192.168.2.1 -p 6543 -l LOGFILE
Client Requirements
Additional requirements:
Request from <CLIENT IP> for <URL>. Redirecting to <Replica IP>, Preference <Preference>, Next Preference was <Next lowest preference> to <Replica IP>
Response from <Replica IP>, sending request to <Client IP>
"Error: Unable to handle request between <Client IP>, <Replica IP>, <Preference>, <Error details>
tc qdisc add dev <ethernet device, e.g, eth0> root netem delay 200ms
tc qdisc add dev <ethernet device, e.g, eth0> root netem loss 20%
tc qdisc del dev eth0