Scenario 1. (be denied)
Plus Redis, MongoDB read and write separation, a single process from MongoDB in time to synchronize tasks to Redis.
It looks perfect, but there are all sorts of questions coming up on the line, listing:
How much is the 1.Redis queue length appropriate?
2. How many tasks are appropriate for the synchronization process from MongoDB to Redis based on priority? Too big to cause a lot of unnecessary overhead, too small to operate MongoDB frequently
3. When a sub-task is processed slowly, it causes MongoDB to have a higher priority task without ending, and the lower priority does not get processed, causing the consumer to idle
Final Solution:
While the producer is generating a task, to the Redis synchronization task, the Redis sort set (ordered set, guaranteed priority order), the consumer through the RPC call, the RPC server removes the task from Redis and then ends the task and deletes it from MongoDB.
Test results, Redis insertion efficiency. Redis-benchmark concurrent 150,32byte A task, total 100W, insertion efficiency 7.3W (no persistence used)
Before that, our worries were not necessary, and Redis had a very good performance.
At present, this system can be competent for 5KW of daily tasks, I believe can be more.
Redis+mongodb best Practices for read-write separation-excerpt from the network