1

Can you run a standard Website and a Cloud Service on a single VM in Azure? I'm trying to figure out if I can run a website with a worker role for background jobs in a single Large VM instance.

Note: Large was chosen mainly for RAM requirements of the website, the background services should be fairly lightweight.

Edit: If they can't run on the same VM would having a Web Role and a Worker Role be the next best option? Would that require me to manage the VM?

Daniel Little
  • 16,975
  • 12
  • 69
  • 93

2 Answers2

3

No, the Windows Azure Web Sites do not coexist with a Cloud Service; however, you can certainly run a Cloud Service Web role that spins up other things in the background. You can do this by either including the code you wish to execute in the web site package and then spinning it up via a ProcessStart in the OnStart for the role entry point, or you can spin it up using a start up task (http://msdn.microsoft.com/en-us/library/windowsazure/hh127476.aspx).

Why have you chosen a Large to run it in? Is that because it needs the heavier power for the background work? If so, you could get the same cost from a Small and a Medium, or even less for two smalls. Don't forget that if your "worker process" is CPU intensive it could crush the machine and starve out the web processing.

I'm all for hosting multiple processes on the same VM, especially for workers, but I'd be skeptical of doing this with a web role involved if it sees a lot of traffic.

Another option if you aren't required to use the PaaS model is to use the new IaaS (Windows Azure Virtual Machines) and run both IIS and a Windows Service on it to serve as the background worker; however, doing this means you'll own and have to care for the VM for patching, etc.

MikeWo
  • 10,887
  • 1
  • 38
  • 44
  • Large was chosen mainly for RAM requirements of the website, the background services should be fairly lightweight. – Daniel Little Jul 18 '13 at 01:49
  • What about a Web and Worker Role combination? – Daniel Little Jul 18 '13 at 01:53
  • As I mentioned, you can run code in the background of a web role, so you could spin up your back ground process but it wouldn't be a Worker role per se. See the link I provided on start up tasks. Technically the worker roles also have IIS installed so you could write a start up task on a defined worker role to configure your web site, but I'd suggest using the web role and run the work process in the background if you really need to combine. Can you provide some more info on what the background process is doing to see if it makes sense to combine? – MikeWo Jul 18 '13 at 02:30
  • It's just a service that reads emails queued in a database then sends them and marks them as sent. More similar jobs may be added in the future. I'd like to keep them separate so I can scale the website separately. I'm looking for a lightweight method for running background tasks that can be used in conjunction with websites in a PAAS manner. – Daniel Little Jul 18 '13 at 03:06
  • I don't think Azure provides anything that is exactly what I'm after. – Daniel Little Jul 18 '13 at 03:18
  • Azure can certainly do what you are talking about. From your description I'd say you don't really want to combine the website with the worker, especially when you say you want to scale the website separately. Take a look at the Windows Azure Mobile Services Task Scheduling capability which kick off those background tasks http://fabriccontroller.net/blog/posts/job-scheduling-in-windows-azure/. There is also a Kron based scheduler in the Azure Store that can be used. – MikeWo Jul 18 '13 at 10:15
  • It can do it, however it feels like there should be a better way. Calling a URL to invoke background tasks is not reliable especially for long running tasks. It's something that I've seen implemented poorly many times and has always lead to pain. Azure should look at providing a simplified version of workers like AppHarbor that can run as a service and are as easy to deploy as Websites. – Daniel Little Jul 19 '13 at 03:28
  • I also don't like the fact that using Azure Mobile Services Task Scheduling would fragment the application and also stop me from packaging and deploying as one unit. – Daniel Little Jul 19 '13 at 03:33
  • I've asked a new question to kind of make sense of what I'm trying to get out of these comments. I think it shows where I'm coming from a lot better. – Daniel Little Jul 19 '13 at 06:05
0

Great news.. You can now do this!

Introducing Windows Azure Web Jobs

  • Azure Web Jobs make scheduled background tasks a breeze for Azure Web Sites.

So now you can have a single PaaS website and background services without even looking at Workers or Roles!

Daniel Little
  • 16,975
  • 12
  • 69
  • 93