1. Scenario description:
Now the local database needs to synchronize inventory (field) information with the pharmacy database. The way to achieve this is to call the pharmacy's interface to obtain the inventory of a single drug.
2. Solution:
Scheduled task time, if synchronization occurs every few minutes (for example: 2 minutes), I query the local database to traverse each record and adjust the interface to update each record.
3. Question:
There are tens of thousands of data in the local database. If the operation memory is taken out at the same time, it will definitely explode. Moreover, the synchronization has not been completed in 2 minutes. What should I do if I re-execute it?
It's a bit vague idea, take it in chunks, for example, take 100 items at a time to update. How to design and test to achieve better results?
I don’t quite understand the requirements, so I can only give you a reference:
1. If you have permission to modify the pharmacy database:
2. If you do not have the right to modify the pharmacy database:
The author first confirms that by calling the inventory of a single drug through the interface, can you check it all in 2 minutes? If so, it is better to use Redis to save such frequent IO operations first, and then make a scheduled task and insert it into the database later.