Find Mutual Friends
Sometimes, you just don’t have enough computation power to solve a problem, regardless of how good your code is. That is when we jump on to parallelism, where you take independent tasks and have them compute in parallel on separate processors. The following diagram shows parallelism.
It basically divides the task and does them independently with different workers. In this project, we will simulate the MapReduce framework on the problem of “Finding Mutual Friends.” Before first, let’s take a look at MapReduce.
MapReduce is a framework for carrying out large scale distributed computing.The MapReduce framework consists of the two phases:
Map: Takes input data and maps it into the form of key-value pairs. This is where the input data is processed before handing onto the reduce function. This procedure can be done in parallel as all data processing is independent of each other. The output is grouped under a single key before handing onto the reduce function.
Reduce: This processes the output from the map function and reduces it into the final output.
The above diagram shows an outline of the entire process. Notice that map and reduce phases are done in parallel.
In this project, we will simulate this MapReduce concept to finding mutual friends in a group of people.
A company wants to create a social media application called "FriendMe". This app will promote socializing between employees across offices. The application is almost complete but they need a feature that finds mutual friends between users. This feature can make users more comfortable with the app. Given that they have distributed servers across the globe, the CTO wants to use the MapReduce framework to implement this feature, distributing the computation overhead. The CTO wants you to simulate this feature in JavaScript.
Your task in this project is to use your JavaScript knowledge to help implement the simulation of the MapReduce framework. Then, the CTO will know if it is possible to create a MapReduce implementation for the company’s servers.