cdub
cdub

Reputation: 25701

Does an asychronous web request in .Net help performance

What is the performance difference, if any, between a regular request in C# .net and an asychronous one?

Upvotes: 0

Views: 237

Answers (3)

Jonas Høgh
Jonas Høgh

Reputation: 10874

Depends on your use case. While there is no immediate performance benefit from using async in simple scenarios, it can be crucial in more complex ones, and for scalability.

For instance, sending multiple requests to many servers is obviously best done in parallel, this can be handled using async.

Regarding scalability, consider a web application that uses sync web requests to communicate with slow external servers. Since IIS only allocates a limited amount of threads to serve requests from users, when the number of users grow, there is a risk that all user threads will be blocked while waiting for the external web requests. This means that some user requests will be rejected by IIS.

Upvotes: 1

jasonjifly
jasonjifly

Reputation: 347

under asychronous mode, The server can only reply what you want, this will minimize the network triffic, then minimize the response time, improve the user experience.

Upvotes: 0

jamesbar2
jamesbar2

Reputation: 614

It depends, in asp.net you must use synchronous (until 4.5); but in a Windows Form or any other type of C# project though, it prevents the thread from being on hold. Calling the ASYNC complete event, would allow you to update the proper information without putting the UI or the Main thread on hold.

Upvotes: 0

Related Questions