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/redirector”. 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/redirector. 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). 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.
Note that the load balancer does not act as a proxy. It simply tells the clients which server to connect to.
The client and server communications may use TCP or UDP.
Replica Server Specifications
The replica server takes three arguments:
$ replicaserver -p <PORT> -s <LOG FILE LOCATION> -w <web page to download>
1.PORT
- The port server listens on.
2.Log file location
- Where you will keep a record of actions.
3.w
- Which webpage to download and serve.
For example:
$ replicaserver -p 30000 -l /tmp/logfile -w www.nytimes.com
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
The client (we name it anonclient) takes four arguments:
$ anonclient -s <LOAD-BALANCER-IP> -p <PORT> -l LOGFILE -f <file_to_write_to>
The client takes three arguments:
1.LOAD-BALANCER-IP
- The IP address of the load-balancer/redirector.
2.PORT
- The port the server listens on.
2.Log file location
- Where you will keep a record of packets you received.
2.File to write to
- Where you will write the retrieved content.
For example:
$ anonclient -s 192.168.2.1 -p 6543 -l LOGFILE -f test.txt
Client Requirements
Functional requirements
Protocol Specifications:
Additional requirements:
Request from <CLIENT IP>. Redirecting to <Replica IP>, Preference <Preference>, Next Preference was <Next lowest preference> to <Replica IP>
"Error: Unable to handle request between <Client IP>, <Replica IP>, <Preference>, <Error details>
apt-get install -y kernel-modules-extra
apt-get install -y kernel-debug-modules-extra
reboot
Add loss or Delay
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%
Reset loss or delay
tc qdisc add dev <ethernet device, e.g, eth0> root netem delay <new delay>
Delete everything
tc qdisc del dev eth0 root