Speed up process in .NET/C# - calling web-service and doing database inserts/updates inside loop

In C#, 3.5, have a for loop.  Inside the for loop, call a web-service (which takes about 2 seconds for each iteraton)   and then do couple of database inserts/updates (these take .5 secs each).  But that is only for 1 iteration.  So if I have 3000 entries, takes a real long time. Any ideas to speed this up, like asynchronous way.  What is a best-practice to solve this problem, as this is a sequential flow inside a loop.
tapdev72Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ambienceCommented:
Various things
- Consider Batch operations, like bundling a few operations in a single web-service request
- Asynchronous operations will only make your application more respnsive, but also you can issue more than one request at the same time and that may increase the throughput.
- Merge insert/update into a single operation by the use a stored proc?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lucky_jamesCommented:
As ambience has already said, you can bundle multiple calls and do the same task in a single communication across layers....be it the communication with web service.or calling stored procedures in db.
Also, look at how you can reduce the turn around time in each layer, this can be done by tuning the performance at each layer. use of multiple threads in C# code, indexes in db etc. and of course doing the asynchronous operations.
0
dshrivallabhCommented:
For X to Y
Call web service
Do insert /Update based on value of X
Next

If this is the case and Insert and Update and not dependant upon the sucess or failure of webservice you can move out the webservice call out of the forloop. Create a concatincated string of values or a structure which can pass the data in bulk to the web service. same is true with the inserts and update...
One SP does it all


0
tapdev72Author Commented:
Its right to an extent.  Samples would have helped. Maybe question is too generic.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.