POST: /api/v1/schedule
inputs:
outputs:
GET: /api/v1/?task=task_id
inputs:
outputs:
LIST: /api/v1/tasks
inputs:
outputs:
DELETE: /api/v1/?task=task_id
inputs:
outputs:
Since our system is write heavy and our data is more than 5 TB. we will use a column based database that are generally highly scalable for high load and write heavy queries.
we will index on task_id and task_status. Assuming we will have following schema
Task Table
String task_id PRIMARY KEY NOT NULL,
String schedule NOT NULL,
blob task NOT NULL,
String task_status NOT NULL,
Timestamp<tz> last_executed NOT NULL,
Timestamp<tz> next_execution
Task Management table
String task_id PRIMARY KEY NOT NULL,
String schedule NOT NULL,
Blob task NOT NULL,
Boolean is_recurring NOT NULL
It is important to emphasise that, we need time zone aware timestamp to execute task at correct time in correct timezone.
POST
Client -> Task manager -> Add task to Database Table ("Task management") -> Task Scheduler Picks the task and adds it to the message queue -> Execution service consumes the task, Leader co-ordinates with the worker to execute the task and then, add/update task_status in database table "Task" and writes to cache.
DELETE
Client -> Task manager -> Try to Delete a task from the Database Table ("Task management"). If tasks is already in progress meaning it is in the queue, we return error.
GET
Client -> Task manager -> Reads through the cache and returns if not a miss else gets the task from database table "Task"
LIST
Client -> Task manager -> Lists the cache, if the cache is empty we return a message to try later as otherwise we will be putting too much load on our DB which is designed for ready heavy use-cases