C# Programming
09-10-2010, 02:51 AM
I have a web service that recieves calls from a number of clients (600 and growing). This calls a 3rd party web service to return some image data, which is then sent to the client.
If i spam the 3rd party service with several calls at once (around 20+), it grinds to a halt, and takes over 2 seconds per call to return, when it normally takes 0.3 seconds on a single call.
I noticed that if i throttle the calls (added a sleep of 500ms between each web request), the 3rd party runs fine.
The question is, whats the best way/how can i implement a throttling system in my code, so if i receive several calls on different threads, i dont send them all at once, but que them up, so the 3rd party server has time to respond.
Regards,
Gareth.
(FKA gareth111)
If i spam the 3rd party service with several calls at once (around 20+), it grinds to a halt, and takes over 2 seconds per call to return, when it normally takes 0.3 seconds on a single call.
I noticed that if i throttle the calls (added a sleep of 500ms between each web request), the 3rd party runs fine.
The question is, whats the best way/how can i implement a throttling system in my code, so if i receive several calls on different threads, i dont send them all at once, but que them up, so the 3rd party server has time to respond.
Regards,
Gareth.
(FKA gareth111)