Question

I'm designing an ASP.NET web application which is to be hosted in Azure. I plan to resize images that a user uploads on the server side. I've got a library that does this, but currently this happens in the main web front end VM. I'd like to offload this to a worker VM. I understand the pattern for doing this with a queue, but I don't want to return to the user until the task has completed because I plan to display the resized image upon completion of the processed request. So, how can I offload a task that will be performed synchronously? (meaning I won't return from the call site until the remote task has completed.)

Thanks...

-Ben

Was it helpful?

Solution

You can do something similar to what we do in the WebJobs Samples here: http://aspnet.codeplex.com/SourceControl/latest#Samples/AzureWebJobs/PhluffyShuffy/PhluffyShuffyWeb/Views/Shuffle/Index.cshtml

We have a very similar application: process an image and display it when it is done. For that we are just pooling for the result blob using JavaScript.

OTHER TIPS

Holding threads on a web server is usually not a good idea; this negatively impacts scalability.

Consider having a UI JQuery that periodically checks whether the image is ready to be displayed. All you have to do is check for the presence of the image every second or so. There are a couple of ways to do this; in one implementation the client knows ahead of time the name of the image and just attempts to read it (for example a Blob); in another the UI doesn't know the name, but checks a record in an Azure Table that indicates the status of the image creation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top