C# – Building a scalable ASP.NET MVC Web Application


I'm currently in the process of building an ASP.NET MVC web application in c#.

I want to make sure that this application is built so that it can scale out in the future without the need for major re-factoring.

I'm quite keen on using some sort of queue to post any writes to my database base to and have a process which polls that queue asynchronously to perform the update. Once this data has been posted back to the database the client then needs to be updated with the new information. The implication here being that the process to write the data back to the database could take a short while based on business rules executing on the server.

My question is what would be the best way to handle the update from the client\browser perspective.

I'm thinking along the lines of posting the data back to the server and adding it to the queue and immediately sending a response to the client then polling at some frequency to get the updated data. Any best practices or patterns on this would be appreciated.

Also in terms of reading data from the database would you suggest using any particular techniques or would reading straight from db be sufficient given my scenario.

Thought I'd post an update on this as it's been a while. We've actually ended up using Windows Azure but the solution is applicable to other platforms.

What we've ended up doing is using the Windows Azure Queue to post messages\commands to. This is a very quick process and returns immediately. We then have a worker role which processes these messages on another thread. This allows us to minimize any db writes\updates on the web role in theory allowing us to scale more easily.

We handle informing the user via emails or even silently depending on the type of data we are dealing with.

Best Solution

Not sure if this helps but why dont you have an auto refresh on the page every 30 seconds for example. This is sometimes how news feeds work on sports websites, saying the page will be updated every x minutes.

<meta http-equiv="refresh" content="120;url=index.aspx">