-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Interview Question: Design a Task Scheduler
Company: Gameberry Labs (Source)
Context:
You have been tasked with creating a Task Scheduler system that can handle two types of tasks: Single Task and Recurring Task. The system should have the capability to execute tasks based on their type and also support the recurring nature of tasks as per their defined frequency.
Objective:
Design the classes, APIs, and the logic behind executing recurring tasks in the system. Ensure that your design allows for scalability and can handle a large number of tasks efficiently.
Requirements:
-
Classes:
- Define classes for
SingleTaskandRecurringTask. - Define any other supporting classes that you feel would be necessary.
- Ensure that the classes have appropriate attributes and methods to support their functionalities.
- Define classes for
-
APIs:
add_task(task): To add a new task (either single or recurring) to the scheduler.delete_task(task_id): To delete a task from the scheduler using its unique identifier.execute_task(task_id): To manually execute a particular task.get_all_tasks(): To retrieve a list of all scheduled tasks.- Any other API you deem necessary.
-
Logic for executing recurring tasks:
- Define how you would manage the scheduling of recurring tasks.
- Explain how you would handle overlapping tasks or tasks that need to be executed at the same time.
- Discuss how your design would efficiently manage a scenario where there's a large number of tasks in the system.
- Consider error handling: what happens if a task fails? How would you handle retries?
Bonus:
- Consider edge cases such as Daylight Saving Time changes or tasks that need to be scheduled across time zones. How would your system handle these?
- Discuss the potential use of existing scheduling libraries or tools in the development of this system.
Assessment Criteria:
Look for a clear and concise design, well-thought-out logic for task execution, error handling, and scalability considerations. The candidate should also be able to reason about potential bottlenecks in their design and suggest improvements or optimizations.