How to determine if there are running jobs or exiting a user process

In our business scenarios, we have a job queue, one producer process, and several consumer processes. The manufacturer only puts new tasks in the queue when all consumers have no work. The consumer may die or be stuck. If this consumer is no longer working, the producer should think that this dead consumer has completed his work.

We use the redis server as our job queue. How to create a redis data structure to perform this process efficiently?

+4
source share
1 answer

No one answers my question, but I myself came to a decision.

1. , : SET dispatch.finished 0.

2. , : SET dispatch.finished 1

3. : " SADD ID1 ID2"

4. , : SET worker.ID1.busy 1 : EXPIRE worker.ID1.busy 3

5. , , dispatch.finished == 1, : SET worker.ID1.busy 0

6. , , ( ), , 1.

0

All Articles