hjavaher
hjavaher

Reputation: 2609

Multiple Azure Webjob instances on one queue

I'm looking for a way to have multiple instances of my azure webjob running together and clearing my queue.

One of the functions of our application is to decrease the user's credit on every page view on their site (called by an ajax). We currently have close to 600 of these websites and every page view of their site is generating a call that results in a credit being deducted from their account (SQL Azure).

This happens real time in the and we are calling the sql server on ever one of these calls. So far it's working fine but I'd like to offload this task to the webjobs and a queue since I believe that is a better way of doing this.

My question is, how do I setup the webjob or a series of them to work with the same queue and work together to finish everything in the queue. Is there a way of spinning up more of them if lets say the queue reaches a high amount of massages?

I've searched everywhere this morning for this information but unfortunately I can't find anything on this.

Upvotes: 0

Views: 2951

Answers (1)

Victor Hurdugaci
Victor Hurdugaci

Reputation: 28425

You can write a web job, using the Azure WebJobs SDK, that is triggered by the messages in your queue and then spin up multiple instances (by scaling). Each job instance will pick a different message from the queue.

You can use the Azure Websites scale feature. Each extra website instance means an extra webjobs instance too. http://azure.microsoft.com/en-us/documentation/articles/web-sites-scale/

If you want to scale based on the number of queue messages, it think (not sure!) that you can use the management API to scale programmatically.

Upvotes: 2

Related Questions