Amazon Interview Question
SDE-2sCountry: United States
Interview Type: In-Person
The job scheduler can facilitate the client to create a queue of its own with configurable values like timeouts, retry counts, consumption logic, priority and user permissions.
For every queue, the client should be able to create, delete and cancel the execution of the job.The jobs can also belong to a definite group.All the jobs in a particular group will be executed in sequence.
We will have a logic around the failed jobs depending on the status code of the response.If the job has failed with 5XX, it will be sent to a retry queue.If the job has failed with 4XX, it can be sidelined and sent to the sidelined queue.The client can see the sidelined queue and can take corrective action.
We will be able to set a number of consumers of the job queue depending on the load.
In simple terms,
- Object June 02, 20171. UI: A task should have task id and start time to execute. User has the provision to create/view list of tasks and its status.
2. DB: A table to model task. Columns to hold task id and schedule.
3. Middle tier:
3a. A poling logic in specific time interval which queries the table to retrieve the task whose time has expired.
3b. Each of the retrieved tasks could be added to a thread pool. A thread pool would contain fixed number of threads each carrying out a task at a time. The basic operations of the Thread Pool can be to add task, start the tasks etc. Thread Pool class would have a queue which holds added tasks. A task object can have its Id, Start Time, Status, operations to start/stop/pause. Time slicing or some greedy technique could be introduced to handle long running tasks.