I was hoping I'd be able to find Azure billing 'use cases' somewhere on the MS site or on StackOverflow.
Maybe I'm being paranoid but I'm trying to be certain before I tell a customer that it'll cost $XXX.00 to move his app to Azure.
I've got an MVC site running on a server in his office. It's a data-based app using SQL-Server. Data intensive but just about 20-30 users. The purpose of going to "The Cloud" is not scalability but reliability.
Lets just say I need a Cloud Service with 2 medium VMs (2 so that we have fail-over capability) and a 1GB SQL Database. Say $2 worth of Bandwidth (15 gb) would probably be enough. Geo Redundant Storage: all the stuff besides the DB is comprised of Code. Very little in the way of resources, total less than 20 megs.
So, my question: By running a Web and Worker am I using two instances? One for Web and one for Worker? If so, can I run the app in just a Web Role? I don't run a separate service. What if I did run both Web and Worker roles for the same site, would that be an extra instance (4 instances instead of 2)?
So, by running a Web and/or Worker role am I ALSO incuring a Virtual Machine instance? If not, does the scenario change if I occasionally RDP into the Web/Worker instance?
Thanks for any insight into this. Also, does anyone know of a MS site that has billing 'use cases' like this?
Based on your description, I'm not sure why you'd want a Worker role. Worker roles are ideal for handling transactions, processing, etc. but I'm not sure if you need that. For example, worker roles can process submitted orders, resize images, etc. Basically any process that you'd like to abstract from the user interface.
Since you mention that you want fail-over capability, you should probably use at least two of whatever role(s) you choose. For example you will need a Web role for your MVC web site. You'll need two instances of whatever size you choose to qualify for Microsoft's Cloud Services SLA uptime guarantee of 99.5%.
Should you decide you need a Worker role, you'd need two instances of that as well.
It's not required to use a minimum of two instances per role type, but it's certainly recommended for production apps, and is required for SLA coverage.
you get charged for each role you activate, so web and worker role will be separate. as far as combining the worker and web together, not sure progrmatically how the
Ok lets take this one by one.
By running a Web Role and a Worker role while meeting the SLA criteria of having at least 2 instances of each role you are essentially creating 4 billable instances (2 Web Role instances and 2 Worker role instances)
You can definitely run a service within a web role if that suits your purposes and save on the worker instances. In that case you'd only have 2 billable instances.
No the VM role is a completely difference role type and you are not running a VM role by running Web/Workers. You can always safely RDP into the instances irrespective of the role type (However the merit of such an act is questionable once you are in production).
Related
I've deployed web sites and services to the cloud before but it was a while ago and I wanted to revisit my approach to inventorize my skills. During the research, I've been told to use a worker role but I'm not sure in what constellation to apply it.
The image presents my choices. I'll be setting up two things (preferably on the same base URL).
1. A web site (ASP.NET, most likely MVC powered by Razor)
2. A service layer (guessingly WCF, as there's not much else to pick from today)
So, in my naive ignorance, I added ASP.NET Web Role for the former and WCF Service Web Role for the latter. Then, according to the hint, I also added Worker Role. And this is where I got humble and started to suspect that my ignorance was rather an arrogance...
Do I need all the three of them? Or is it perhaps so that Worker Role covers the others? Or are the others sufficient and I need to Worker Role? Or am I totally confusing the concepts here?
I've tried to google those but I realize that I haven't reached the threshold of learning by doing in this area yet. I get more confused and headacheish the more I read. Admittedly, my problem might lie in the wrong choice of search words and/or linguistic misconception. If so, my apologies...
The answer is, it depends...
A web role is essentially a Worker role with IIS installed + configured. You could host a WebApi/MVC, WCF AND process events all from the same web role if you really wanted to, reducing costs.
Remember that each role is a separate VM that you have to pay for, so adding extras roles to keep everything separate may not always be the best idea.
In one of our projects for example, we use a web role to host a WebApi. A Worker role to process internal events, and a worker role to host WCF services (you can also use a web role for this). We split them because they take very different workloads and perform separate functions, so being able to scale them independently made sense.
HTH
There's no right answer to how many roles to use in a cloud service. But it's important to understand exactly what those roles are.
Adding a bit to #Peter's answer: Each role is a definition of a VM (its contents) - think of it as a VM template. And for each role (template), you must have a minimum of one instance (VM) running. If you have one role, your minimum footprint will be one VM (of whichever size you specify for that role). If you have three roles, you'll have minimum 3 VMs running.
Whether you have one role or many depends on how you want to scale your application. Each role defines not only what goes in it, but also the size of the VMs uses by the role instances. By having different roles for different parts of your architecture, you can choose to scale those parts differently. For example, you might only need low-resource instances to handle your web tier, but maybe more CPU power for your service tier. And maybe your web tier scales dynamically based on user traffic, but you're able to handle, say, your service tier with just one or two instances. Of course, you can put everything in one role definition, and scale everything together. It's totally up to you.
We have a VM say SampleVM depoyed & running on Azure Environment and on the same we have created 2 instances One is WebRole & other is WorkerRole running onto Slot staging.
My prob is I am able to Start/Stop SampleVM through powershell command but How can I Start/Stop a single instance(WebRole or WorkerRole) running on a SampleVM.
However when I stop SampleVM then both the Instance also stopped but I want to stop only one Instance/VM i.e. WebRole Or WorkerRole.
Please provide some powershell command with the argument pass to Stop/Start a single instance
Good answer by Gaurav, but I wanted to add a bit more detail, as I think there may be a bit of confusion around web and worker roles. Each role is a definition for a group of virtual machines that do the same thing, as constructed by you (you don't deal with the OS - you just kickstart your app, and Azure takes care of the VM itself).
When a Cloud Service is running, there will be a minimum of one instance of each role type. So in your case, running both a web role and worker role, you'll have at least two VMs running.
If you choose to scale out your web role to, say, 3 instances, and then decide to dial it back to 2 instances, you cannot choose which one to shut down; this is taken care of by Azure's fabric. Remember that each instance of a role is running identical code, and Azure load-balances traffic to your role instances (through external endpoints that you define). The only thing you need to worry about is shutdown. You have approx. 5 minutes to clean up any running processes (and you can easily take a particular instance out of the load balancer during shutdown, since you receive a Stopping() event).
You cannot shut down an entire role (e.g. all instances of a role) within a cloud service (so... you can't take down your worker role instances while leaving your web role instances running). If that's a requirement, then you can always consider running your web role in one Cloud Service and worker role in another Cloud Service. If they use queues to pass data, everything will still work as before. If the web role instances need direct access to worker role instances, you could put both Cloud Services into a Virtual Network.
One more thing to consider: You don't have to have separate roles. If cost is a factor, you can run all your code in your web role. Takes little work to spin up additional processes / threads in your web role, during OnStart() - remember that role instances are full Windows Server virtual machines; run whatever you want. With a single role definition, scaling is a bit coarse: Everything is scaled together. With separate roles, you can fine-tune your scaling (much more important when building larger systems).
David's broader points about how to model your PaaS service are all correct. But to add to it, there is a new Service Management API that has just been released called Delete Role Instance which will let you delete a specific instance of a role - http://msdn.microsoft.com/en-us/library/windowsazure/dn469418.aspx. This functionality is brand new to allow you to choose which instance to delete instead of being subject to the default fabric behavior that David describes (always deleting the last instance).
Simple answer is that as of today, you can't stop a single instance of your web/worker role. When you stop a role, all instances are stopped. You could remove instances from your role but again you can't specify which particular instance you want to remove. See #kwill's answer below.
You may also find following links useful for deleting specific role instances:
http://gauravmantri.com/2013/10/16/a-new-version-of-windows-azure-service-management-api-is-available-with-delete-specific-role-instances-and-more-goodies/
https://github.com/richorama/Two10.Azure.SelfDestruct
I am just about to move my website, database and a background scheduler onto the Azure platform.
I've to use cloud services with web & worker role. Now my question is that do I need separate instances for each type of role, or one instance is capable of hosting multiple types of role ?
You cannot have a combined web and worker role instance. It can be one or the other. However, it is possible to have the web role do background processing, so it can host the background workload.
See this SO question for a couple of options
Azure WebRole Scheduled Task Every Morning
That talks about running a task each morning. Obviously you can do it more frequently, as appropriate for your application.
Be aware of the scalability limitations of this though. Once your traffic ramps up, it will make sense to break it out into separate web and worker roles.
In fact, even if your background workload is light, it might still make more sense for you to go for a separate architecture from the start and use XS instances for the background processing.
Technically you can't have a role of both types. Yet a web role is just the same as a worker role, it just has IIS configured. So you can merge them into one web role - IIS will run in a separate process and role entry point Run() will run some endless loop for "backend" processing. See this similar question.
This will make scaling more complicated. The whole idea of separate roles (remember you can have not only one web role and one worker role, you can have for example four worker roles and two web roles if that's appropriate for your solution) is that you can scale them separately.
It looks like once you merge two roles into one you no longer can fine scale them. This is not true most of the time - you just have to change metrics.
For example, you wanted to run one web role instance for each thousand HTTP requests per minute and one worker role instance for each ten requests in the backend queue. Okay, this means that each thousand HTTP requests needs the same amount of processing power as ten items in the backend queue. So you craft a new metric that takes both parameters and deduces a number of instances. Like you have five thousand requests per minute and twenty requests in the backend queue - you need seven instances of am merged role.
This won't work for all applications, but most of them will use this approach just fine. The bonus is that you avoid cases when either of the roles in idling because the current load gets onto another role.
Is it possible to deploy multiple roles in the same instance?
I have three web roles (website in asp.net mvc3, and two WCF services instances) and two worker roles (windows services).
The load for this application is very small, so I don't want to create so many instances in Windows Azure and pay for all of the instances now. Instead I want to deploy all my application in the same instance and change it later if I will get some income from my applications.
I Googled and found some forum posts than it's possible and some than it's not possible... but I can't find information how to do it...
So two questions:
Is it possible?
How can I do it?
A slightly different answer than #Simon's... A Role is actually a template for a Windows Server 2008 VM (see my answer on this SO question as well). Each role has one or more instances, and you can run whatever you want on any role.
You can absolutely run your website and all your WCF services in a single role. You'll now scale your application up/down (VM size) and out/in (# of instances) as a single scale unit. If, say, your WCF services are CPU-intensive, causing the VM instances to slow down for your web visitors, you'll need to scale out enough to handle those visitors.
Once you reach a significant traffic load, it's worth considering separate roles. That way, you can decide on VM size and quantity per role. Maybe you have 2 or 3 Small instances of a Web role to handle your user traffic on the website, and maybe 2 Medium instances of a Worker role to handle WCF services (just as an example). The more roles you have, the finer-grain scaling you have, but you must run at least one instance of each role, which elevates your "system at rest" baseline cost.
No, roles are instances and each one takes up an entire VM. You can however deploy a number of websites into a single role, which will allow you to deploy all your MVC and WCF apps into a single web role. You need to add websites to the sites element in the ServiceDefinition. There seem to be a few blog posts on how this is done - here and here.
For worker roles, I suggest you create a single worker role and combine the work done in those roles, such as starting a separate thread for each queue being monitored. This StackOverflow answer by Eugenio Pace.
I wouldn't recommend trying to combine worker role functionality into the web role. Apart from it not making architectural sense, sense to the physical infrastructure (IIS vs not IIS), there are potential issues such as the with termination of running threads when worker roles recycle (a thread not started by IIS may terminate abruptly)
Check this episode of cloud cover.
you can put couple of web role in the same instance.
worker role you can always put multiple thread to work the data.
http://channel9.msdn.com/Shows/Cloud+Cover/Cloud-Cover-Episode-37-Multiple-Websites-in-a-Web-Role.
Note that each time you upload a new version to azure you need to upload all the web roles/ worker roles to azure again
Check out this blog post 'Combining Multiple Azure Worker Roles into an Azure Web Role'
http://www.31a2ba2a-b718-11dc-8314-0800200c9a66.com/2012/02/combining-multiple-azure-worker-roles.html
I think this is what you need to do...
Also Wayne has variations of this on his blog: http://www.31a2ba2a-b718-11dc-8314-0800200c9a66.com/2010/12/how-to-combine-worker-and-web-role-in.html
HTH
I know that you can only have 1 web role per instance but does this apply to Background roles as well? In more detail can 1 instance run a background role and a web role?
I think the terminology used in your question is confusing the other responders.
In Windows Azure compute, you have a cloud service. A cloud service can be thought of as your overall architecture, or at least the front end, the middle tier, etc (any tier where there is compute as opposed to storage). For example your application might have a presentation front end (ASP.Net MVC web application) and a middle tier (WCF service layer over basic http). We liken each of these tiers to "roles". So in my example above, I would have 2 web roles in my cloud service. I might also have some back end processing which does some sort of batch work, this would be a "role" also. Roles that respond to user interaction such as web sites, service layers, etc are hosted as "web roles" while those back end services are "worker roles".
Then we have instances. An instance is how many virtual machines are provisioned to provide the functionality of a given role. For example, I might need my presentation tier to have 5 instances because it takes a lot of load. So, my 1 web role has 5 instances. Likewise my middle tier, a service layer, might only need 3 instances (because of presentation tier caching) and so therefore my 1 web role has 3 instances. My back end service might only need 1 instance since its job can be done whenever, but if the back log gets too big, it could scale up to 10 instances to get through the work, then scale back down to 1 instance again.
So the key here is that you can have 1 or more instances per role. Because of this relationship it makes sense that you can have only one role per instance (since an instance is 'instantiated' from a single role template).
What Rinat was trying to say above was that you can cheat with the worker role and actually host a http end point in WCF, thus getting web role type behavior, however you don't get the load balancing of a web role when you do this. Likewise, a web role can have worker role style behavior by overriding the OnStart method in the WebRole.cs. However I would still argue this is just one role in both cases, and you can have multiple instances of that role.
Bjorn was indicating that by default you are capped at 20 instances per role, however you can get more (so he doesn't deserve a -1 IMHO).
Hope this clears it up.
You can have only one role per instance.
However, you can host Http endpoint in your worker role, effectively turning it into Web+Worker role.
References and samples:
Windows Azure Hosted Web Core Worker Role
Redirect Tcp Connections in Windows Azure
By default one web role can have 20 instances. If you need more you can contact the Azure Service Desk and they will turn it up!