As long as it is a round robin, there will definitely be this time interval. Mysql does not seem to have a data monitoring mechanism You can add a layer of redis or mq in front 1. Add a task to the front end 2. Write the task to redis/mq and write it to mysql 3. The backend monitors redis/mq and gets the task Execute, update mysql after execution is completed
Needless to say, mq is all used to monitor redis using pubsub. redis pubsub is very simple to use. http://redis.cn/commands/pubs... In this way, the backend can also perform tasks concurrently
The front-end should not be able to directly write to the database. The front-end should send the request, and the back-end will execute the front-end's request. Then after the back-end completes the write operation to the database, it can directly send another message requesting the execution of the task. Of course, this message can also be initiated by the front-end after the front-end receives the successful writing message. However, this seems unreasonable and wastes server resources. In this way, the way the backend performs tasks should not be polling, but should be changed to listening for responses. When the execution request of a new task is monitored, the data is fetched from the database and added to the task queue.
Add machine...
As long as it is a round robin, there will definitely be this time interval.
Mysql does not seem to have a data monitoring mechanism
You can add a layer of redis or mq in front
1. Add a task to the front end
2. Write the task to redis/mq and write it to mysql
3. The backend monitors redis/mq and gets the task Execute, update mysql after execution is completed
Needless to say, mq is all used to monitor
redis using pubsub.
redis pubsub is very simple to use. http://redis.cn/commands/pubs...
In this way, the backend can also perform tasks concurrently
The front-end should not be able to directly write to the database. The front-end should send the request, and the back-end will execute the front-end's request. Then after the back-end completes the write operation to the database, it can directly send another message requesting the execution of the task.
Of course, this message can also be initiated by the front-end after the front-end receives the successful writing message. However, this seems unreasonable and wastes server resources.
In this way, the way the backend performs tasks should not be polling, but should be changed to listening for responses. When the execution request of a new task is monitored, the data is fetched from the database and added to the task queue.