views:

520

answers:

3

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.

+1  A: 

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">
David Liddle
Thanks, I like the sound of using something like this. I'll look into it.
gsobocinski
A: 

Why not let the user manually poll the status of the request? This is how your typical e-commerce app is implemented. When you purchase something online, the order is submitted to a queue for fullfillment. After it's submitted, the user is presented with a "Thank you for your order" page and a link where they can check the status of the order. The user can visit the link anytime to check the status, no need for an auto-poll mechanism.

Is your scenario so different from this?

DSO
Thanks, but I don't think this will fit in with the application. It might be useful to say that this is more of a line of business app where users won't always want to have to go back and check on the status of something. Generally speaking I prefer to automate as much as possible for the user as well.
gsobocinski
A: 

Sorry in my previous answer I might have misunderstood. I was talking of a "queue" as something stored in a SQL DB, but it seems on reading your post again you are may be talking about a separate message queueing component like MSMQ or JMS?

I would never put a message queue in the front end, between a user and backend SQL DB. Queues are good for scaling across time, which is suitable between backend components, where variances in processing times are acceptable (e.g. order fulfillment)... when dealing with users, this variance is usually not acceptable.

DSO
The idea behind using the message queue was to free up the asp.net worker process from any potentially blocking I\O, db writes in my case.I've read a few articles which suggest using this is a good method to scale web applications and removes some dependency between the web front end and my application tier. Of course you would need to do something with the UI to negate the fact that things are being queued to make it immediately responsive, which is probably pushing me more towards an AJAX like approach. For example on a post having some kind of "Please Wait" graphic.
gsobocinski