Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

our team is mantaining and developing a .NET web service written in C#. We have stress tested the web service's farm and we have evidence that the actual architecture doesn't scale well, as the number of request are constantly increasing.

We analyzed Martin Fowler's conclusion in this article, and our team feels that migrating to an asynchronous programming model such as the one described could be the right direction to point to for our service too. My question is: do you think that this "switch" needs a complete rewrite of the application? Has been someone of you been able to adopt APM without rewriting everything and has some insight to share?

Thank you in advance

share|improve this question
Well, do you actually need to rewrite the whole application? Wouldn't modifying just the bits that are blocking the longest be enough? – svick Nov 27 '12 at 10:42
Bits that are blocking are calls to external services whose response is needed in order, for our service, to provide a meaningful response. What I am investigating is the better approach to refactor this kind of "dependency". – Simone Nov 27 '12 at 11:43
up vote 3 down vote accepted

Use the async and await keywords in C# 5.0. These keywords allow you to insert the async functionality into the method calls that require it, without having to create callback mechanisms. The callbacks are created for you automatically by the compiler, under the covers. This should greatly simplify the refactoring effort.

Anders Hejlsberg describes the async functionality in this video, with a detailed example application and demonstration.

share|improve this answer
Thank you Robert, unfortunately at the moment switching to 5.0 is not an option. – Simone Nov 28 '12 at 8:48

Bits that are blocking are calls to external services whose response is needed in order, for our service, to provide a meaningful response.

Is there more processing you could do while waiting for the response from these external service calls? If not then you are out of luck async will only buy you performance if you are able to do more in parallel.

On the other hand if these external services are the only thing needing to be executed in parallel, I would look into futures, they seem like a good fit for kicking off a service call then doing something else while waiting for the result as well as the fact that they would be minimally invasive to your current design.

share|improve this answer
Thank you, I will investigate further on futures. By the way, there's not much processing that I can do while waiting for external service's response and we found.. – Simone Nov 28 '12 at 8:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.