How to use a database server for distributed task scheduling?

I have about 100 computers and several workers on each of them. Already connect to the central database to request job parameters.

Now I need to carry out job scheduling for them. One work for one employee takes several minutes, does not require a network connection (except for tasks and reports) and can be performed at any time in any order.

Limitations:

  • no work will be done / done twice
  • there will be a time when the worker dies.

I thought that I could use a separate table in the database to schedule tasks. How to create and access a job scheduling table?

+3
source share
2 answers

Divide it into parts:

You have a description of the task, which may have some restrictions on where it is performed, and you have a queue of tasks that need to be performed, generally speaking, if there are no other restrictions that you would expect the tasks to be performed in order, t .e. you take them from the front of the line and add them to the end.

If we run the queue in a separate table, then the tasks will have 3 states:

  • Does not work
  • Performed
  • Completed

- ( n , ), , . , n , n , , .

:

  • DateQueued ( )
  • DateStarted ( ) -
  • AssignedTo

, DateCompleted, , ( ).

, ( "" ) :

  • -
    • ( n , )
    • ( , ) - .

, , "-", reset .

.

  • ID
  • JobID - ,
  • StatusID
  • DateQueued
  • DateStarted
  • AssignedToID
  • DateCompleted

, ...

+4

, , .

: , . " " .

, , , . , , .

" " . . .

.

" " , . . , (, "" ).

.

- , - " " . , - .

" " . , , , , . , Postgresql , , .

0

Source: https://habr.com/ru/post/1722854/


All Articles