Case Study - Part1

Real world Case studies


  1. How your email works?
We receive hundreds of emails per day in our inbox for example in our Gmail. Essentially it requires servers to take all the  incoming mails that comes to your emailid , process them properly and show them in your beautiful ui. So some stages that can come in between can be like
  1. Take the incoming mail
  2. Check for Virus
  3. Parse the email
  4. Do Spam Checks.
  5. Deliver to mailbox
  6. Index the emails for search.
If you look at real metrics, there could be billions of mails that can come per day for multiple users.
So what are the real ways in which these real world  applications can scale ? For example, what could be possible ways in which Gmail can scale to process billions of emails per day. ?


Solution:
  1. Bring in queues for each and every process.
  2. User facing servers should be offloaded to increase the speed.
  3. All heavy processes needs to be done offline via queue..


Basically, all heavy processes needs to be broken into smaller parts. Each part needs to be pushed to separate queues via producers. Each of the queues needs to be consumed by respective consumers.


Producers are the servers which will take the incoming mails and put into queue.
Consumers are the servers which will take the data from queue and consume them.


This is the core of producer consumer problem.


So your task is , implement a producer consumer problem in a simplified version.


Solve the above problem using producer-consumer paradigm. Producer thread will recursively traverse the given directory and generate a list of files.There will be a set of threads(that should be configurable) which should  take file names  from producer and compute the number of lines, words and character.
Make sure all the race conditions and synchronization stuff are handled well.


Solution can be found here.

Comments

Popular posts from this blog

Java important topics list for interviews

Tough Sql practise questions for interviews involving SELECT queries - Part 2

DBMS important topics list for interviews

Program to find number lines and words in a given file

Tough Sql practise questions for interviews involving SELECT queries - Part 1

Producer Consumer Problem with Blocking Queue in Java.

Animation for String search - KMP Algorithm

Interactive Data Structure visualizations/animations for algorithms

Replace Occurances of the given string