Case Study - Part1
Real world Case studies
- 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
- Take the incoming mail
- Check for Virus
- Parse the email
- Do Spam Checks.
- Deliver to mailbox
- 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:
- Bring in queues for each and every process.
- User facing servers should be offloaded to increase the speed.
- 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
Post a Comment