I have a database with around 900 records. I need to send each record's info onto a government server and get a response back to update to database. 1 cycle response request takes around 0.3s and so it takes around 5 min to complete the whole task.
I am looking to do it asynchronously. However, it would iterate 900 records in an instant and swamp the server with 900 request in a miniscule amount of time. I am afraid I will DDOS it.
My solution is:
to send them in a batch, like ~30 records each (or any relatively small number). The batch is just a c# List holding the async Tasks.
Then using
Task.WhenAny()
to detect finished tasks, remove them of the off the list and add new async task to it. That way I can keep my requests to a small number.
Is my worry justified and my approach correct? Is there any already available library to limit the number of requests send like this?
Any thought and advice would be appreciated!