Amazon Interview Question
Software Engineer / DevelopersCountry: United States
Msg.Get and Msg.send() are IO bound in the problem statement. So we do not want Msg.Process to wait for a long time to start processing. We should be able to send messages quickly in order to keep Msg.Process. We need 1 thread for Msg.Get for sure and it should be enough as Msg.Get is very lightweight operation.
So if there are n cores and 70% time goes in IO then 7 threads will be able to send 7 * (1-.7) = 2 messages will be sent per unit of time.
So we need 2 threads processors.
final answer is 7(msg.send) + 2(msg.process) + 1 (msg.get) = 10
Assuming the question is asking about thread allocation at the server side specifically.
The number of thread allocation depends on the data on which is being worked on and the load the server is facing.
Please correct me if the argument is flawed. :-)
I would MSG.process() takes the most process and should allocate the most no. of threads. MSG.send() just need to send out the request and that's it. MSG.get() will only need to check whether there is new message and retrieve it.
- Jay March 17, 2013