Expedia Interview Question
Software DevelopersCountry: United States
1. Suppose the API is exposed via RESTful webservice, use a token based mechanism to detect callers, send the token along each call in the HTTP Header, callers which specific tokens have higher priority, after detecting the caller, interrupt any existing running threads to serve the Thread with highest priority, use an OS that supports preemptive task scheduling. After finishing work with thread of highest priority resume unfinished threads.
2. Use a load balancer and a stateless service model, where each request can be treated in isolation inside each server.
I would use a reverse proxy or load-balancer approach, where you will count each incoming request. This is the single point of entry and exit. After this point we do not care which server handles the request. However I would ensure that I capture the token/header information of the incoming call because I need to make sure that the call gets a successful data back.
1. Forced sleep of ( (1/number of threads) + some safety value) sec
- Shrinivas June 09, 20152. By Maintaining list of possible servers and recycling list. for example
list of available servers to call 1,2,3,4,5,6
send first call to server 1 then 2 till 6 and then again 1.