Skip to main content

Project 2 - Load Balancing Simulation

Have you ever wondered how websites are able to handle millions of requests from people all over the world without crashing ?

Here is the answer: 
All the requests that are made to a website are sent to a server which redirects your request to various other servers based on which servers are free and which servers are not free. This process is called Load Balancing. This process can be simulated easily using queues.

All servers operate on a First-In, First-Out (FIFO) basis. You can simulate load balancing by having a queue for each server. The main server which handles the requests will be sending the requests to the other servers in the network in order to be processed. 

But how will the main server know which server to redirect the request to ?
This can be easily solved by maintaining a score for each server. This score will be dependent on the speed of the server, number of different requests that the server is already handling and the approximate time each request might take. Depending on the score of each server, the main server can redirect to the appropriate server. 

Here is the simulation made in Java:


In the top center is the main center. The different colored boxes represent a request. The three bottom boxes represent servers to which the requests are redirected. As each request is processed, they turn bright green. The bottom-left server processes each request at half the speed of the bottom-center server and the bottom-right server processes requests at double the speed of the bottom-center server.

You can find the source code of the simulation here.

This project is a part of a large list of projects based on implementing data structures and algorithms which you can check out here.

If you have any questions or have a project recommendation, feel free to leave a comment below.

Comments

Popular posts from this blog

Project 3 - Analysis of sorting algorithms

Sorting algorithms are one of the most basic as well as one of the most used algorithms. They form the basis for many other data structures and algorithms and are also a great way to learn to analyse algorithms.  In this post, I would like to perform my own analysis of these sorting algorithms to understand where and why various sorting algorithms should be used. My main focus is going to be practical analysis of these sorting algorithms and I am also going to be considering the simplicity of these algorithms. So first, let us think about what basis we are going to use for these sorting algorithms. To analyse any sorting algorithm, let us measure the time it takes to sort an array of integers. The array of integers that we are going to give to the sorting algorithms should be of the following types: Random arrays. Ex: [5, 2, 9, 7, 0, 4]. Sorted arrays. Ex: [3, 5, 7, 8, 11]. Sorted arrays in reverse order. Ex: [14, 11, 7, 3, 1]. Sorted arrays with a few random elements added to the ...

Project 6 - State Space Search - 8-Puzzle

State space search is a process which is used to create simple artificial intelligence. It can be used when the problem can be represented as a set of simple states and the player / agent is the only one who can affect the environment. It allows us to generate a path from the initial state to the goal state (of which there can be many depending on the problem). 8-Puzzle / Sliding Puzzle ,  N-queens  and  Route Finding  are some of the various problems which can be solved using state space search. Let us explore the process of solving the 8-Puzzle problem using various path finding algorithms and comparing how effective each of them is. To get started, we need to start by creating the 8-Puzzle game itself. First, we need a simple way to represent different states of the puzzle. A good way to do this is to store the state as a string. For example: Next up, we need a way to generate the actions that are possible from a particular state. We can  think of it as movin...

Project 1 - Browser linked list implementation

All of us use a browser to surf through the internet. In fact you are using one right now. Have you ever wondered how the forward and backward buttons of the browser work ? Or how the undo and redo functions of your text editor works ? The answer to this is a doubly linked list. A linked list consists of various individual nodes which store some data as well as a pointer to the next node. A doubly linked list has nodes which have pointers to the previous node as well. In a circular linked list, the last node points to the first node. Here is how the application is going to work: Whenever you go to a new website, a new node is added in front of the current node. And the forward and backward button traverse through the linked list.  If you wish to tinker with the code, here is the Github Repository . You can easily expand this program to act like undo and redo buttons of a text editor. Linked list are used in various other practical applications such as photo viewers and music player...