This project presents a distributed system that can be used to perform computations. Using the matrix multiplication as an example, this project will demonstrate how a distributed system works.
So, we have three roles:
- Client - the client is the one who will send the data to the server.
- Manager - the manager is responsible for communicating with the client and workers.
- Worker - the worker is the one who will perform the computation.
Client will send the two matrix (AxB) to our Manager (server) and the Manager will divide those two matrix into chunks and distribute them to the workers. Then the workers will perform the multiplication and send the result back to the Manager. The Manager will merge the result and send it back to the Client.
First of all, clone the repository:
$ git clone https://github.com/progrmoiz/distributed-matrix-multiplication
First of all, let's compile and run the Worker:
$ javac Worker.java
$ java Worker 9001
You can run as many workers as you like and workers can be run on the same network or on different network.
In the case of different network, you can also use Ngrok to expose the port.
Then, we have to first define our worker's IP address and port in the Manager. You can check the Manager's main
function code to see how to do that. Then, we can compile and run the Manager:
$ javac Manager.java
$ java Manager
Manager is by default listening on port 6666.
Then, we can run the Client. You can change the input matrix in the Client's main
function. So, let's now compile and run the Client:
$ javac Client.java
$ java Client
Hurray! You can see the result in the console.
We will be running the code with randomly generated inputs for matrix dimensions of 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192.
We tested the performance with randomly generated inputs for matrix dimensions of 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192.
We work out two examples:
- Single System
- Distributed System (three separate workers)
Processor | Intel® Core™ i7-9700 CPU @ 3.00GHz × 8 |
RAM | 31.3 GiB |
System type | 64-bit Operating System, x64-based processor |
Workers are running separate machines with the same system specs. We are using three workers for this test.