In our application, we need to import transaction data from PayPal through the API for users of my application and store it in the database. I have thousands (about 5k now) of users, and it is growing every day.
This application is a service of Windows.net.
It imports data on an hourly basis for all users. Currently, we import user data one user after another, but sometimes what happens can be so large that the user data is so large that it took about 5 hours to get all of his data, so we block other users. until this import of user data is complete. This hourly import for all other users has completely gone behind the cast.
To avoid this, we thought about creating threads for each user and start them every hour using the Windows service. Here we have a situation where we need to think about bandwidth at any given time, since all threads will start at the same time. Is this a problem at all?
Now, I want to know if our new implementation is correct or not? Also I want to know how this is usually done? If someone has encountered such functionality, please tell us how to do it.
If my question is not clear enough, please let me know, I will provide additional information.
Change If I send so many requests to Paypal from one IP address, how does it handle it? Is there an idea to limit IP requests?
Update: Thanks for all the suggestions and feedback.
I was thinking about using jgauffin solution, as it was a perfect ThreadPool simulation. But here I need a few more functions, such as changing the flow restriction dynamically and recursively calling the callback method.
After much research and analysis of the thread pool, I decided to use SmartThreadPool , which is based on threadpool logic, but with more features. This is not bad and perfectly fulfills my goal.