Sunday, September 26, 2010

Combining Roles on Windows Azure

Now why would you want to do that? Azure provides a nice separation of roles in web role and a worker role – why do you want to combine those you’ll ask. Multiple reasons – saving cost being the primary. The most requested feature on the Windows Azure feature voting forum is “Make it less expensive to run my very small service on Windows Azure.” and rightly so. If you wish to host your “small service” on the cloud it makes sense to minimize the cost. Even for large scale services this can help to maximize the use of resources. Let’s crunch some numbers to see this in action.

Assume that your “simple service” consists of a simple website that provides the UI to the users. There is also a background worker for sending registration emails, sending newsletters and does some nightly batch processing of your data. Let’s say you don’t need a full blown SQL server and are happy with the semi structured data storage that Windows Azure table storage provides. These assumptions are not unrealistic for a large number of  simple websites, in fact most startup websites will start with this model and then scale out as the traffic increases and that’s exactly what Windows Azure enables you to do. So with these very realistic scenario let’s examine what will it cost to host such a service on Windows Azure. We will only focus on the compute cost as that’s what you will save on (& is the biggest cost for a small service) when you combine roles so we can safely ignore the storage, bandwidth and other costs of hosting on Azure as they are all usage based.

Here’s what the compute instances cost on Windows Azure.

  • Small instance (default): $0.12 per hour
  • Medium instance: $0.24 per hour
  • Large instance: $0.48 per hour
  • Extra large instance: $0.96 per hour

Let’s say you will use the small instances for both your roles. So your monthly cost comes out to be,

30 (days in a month) * 24 (hours in a day) * 0.12 (cost per hour) * 2 (number of instances)
= $172.80 per month

Now you are wondering the worker role is just sitting there doing nothing for most of those hours. Shouldn’t you only count the “compute hours” in which the role is actually is alive and doing work instead of the full 24 hours for a day. Well, that’s not how Windows Azure billing work. It’s pay as you go alright but not at that granularity so you end up paying as long as your have reserved the VM, even in the suspended state. May be some day Azure will be able to provide that level of billing granularity – may be we should request that feature on the forum :-) But till then the only way to save cost here will be - if we just got rid of one role entirely and still do all the work with just one role. Turns out it’s very easy to do that on Windows Azure.

To understand how to do that we first need to understand how web and worker role differs in Windows Azure. One obvious difference  is the web role will have an IIS installed on the VM and the work role will not. What else? Well, turns out that’s about it. In every other sense as far as Window Azure is concerned those roles are pretty much the same. You could potentially have your worker role listen on port 8080 and receive web traffic and your web role have a Run()method that does the background work. When you create a Cloud project in Visual studio, by default in the webrole.cs the template does not add a Run() method like it does in your worker role but there is nothing that stops you from doing that either because the WebRole class also derives from the same RoleEntryPoint which workers derive from as well.

public class WebRole : RoleEntryPoint
{
public override void Run()
{
// This is a sample worker implementation. Replace with your logic.
Trace.WriteLine("WorkerRole1 entry point called", "Information");

while (true)
{
Thread.Sleep(10000);
Trace.WriteLine("Working", "Information");
}
}
}

As simple as that. Once your web role gets provisioned Azure fabric will start start IIS and deploy your application as well as start a worker which you can use to do some background processing. The thing to note that both of these processes are running on the same VM and will share the resources so this technique should not be used where a consistently high throughput is required at all the times by either your website or your background worker. But if you are able to use this technique you end up cutting your compute cost in half for your small service.

Hope that helps.



58 comments:

  1. nice piece of information, I had come to know about your internet site from my friend vinay, delhi,i have read atleast 4 posts of yours by now, and let me tell you, your website gives the best and the most interesting information. This is just the kind of information that i had been looking for, i'm already your rss reader now and i would regularly watch out for the new post, once again hats off to you! Thanx a ton once again, Regards windows azure training in hyderabad

    ReplyDelete
    Replies
    1. I feel this is among the such a lot vital info for me. And i am satisfied studying your article. However wanna commentary on few general things, The website style is ideal, the articles is truly nice
      Tangki Panel
      Tangki Fiberglass
      Jual Septic Tank

      Delete
  2. thanks for sharing wonderful blog with us. its really more helpful to our institute candidates to get aware some useful knowledge keep sharing more information.
    Dot Net training in Chennai

    ReplyDelete
  3. I didn't spend much time to visit many websites. But today I found this accidentally and I got more information from your site.
    Regards,
    Windows Azure course in Chennai | Azure Training center in Chennai | Microsoft windows azure Training

    ReplyDelete
  4. best windows azure online training in hyderabad with work support and job assistance and high quality training facilities and well expert faculty
    to Register you free demo please visit
    windows azure training in hyderabad

    ReplyDelete
  5. Nice Blog. Thank you for Sharing. Enterprise Resource Planning Software Solutions in Chennai. For more details contact us info@bravetechnologies.in
    erp in chennai | erp software providers chennai

    ReplyDelete
  6. The best thing is that your blog really informative thanks for your great information!
    erp software in chennai | erp solutions in chennai | erp software development company in chennai

    ReplyDelete
  7. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
    Android Training in Chennai
    Ios Training in Chennai

    ReplyDelete
  8. Good and nice post... thanks for sharing your information... it is very useful to me...
    Android Training in chennai | IOS Training in chennai

    ReplyDelete
  9. Interesting post! This is really helpful for me. I like it! Thanks for sharing!

    Webseiten Gestaltung Lüdenscheid

    ReplyDelete
  10. Interesting post! This is really helpful for me. I like it! Thanks for sharing!
    microsoft office online

    ReplyDelete


  11. Nice and good article. It is very useful for me to learn and understand easily. Thanks for sharing your valuable information and time. Please keep updating. Power BI Online Training .

    ReplyDelete
  12. Interesting post! This is really helpful for me. I like it! Thanks for sharing!
    WebDesign Lüdenscheid

    ReplyDelete
  13. The strategy you posted was nice. Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site.
    Photoshop Training Institute in Chennai | Photoshop Training Institute in Velachery

    ReplyDelete
  14. It’s hard to come by experienced people about this subject, but you seem like you know what you’re talking about! Thanks

    Coreldraw Training Institute in Chennai | Photoshop Training Institute in Chennai | CorelDraw Training Institute in Velachery

    ReplyDelete
  15. I enjoy what you guys are usually up too. This sort of clever work and coverage! Keep up the wonderful works guys I’ve added you guys to my blog roll..,

    white label website builder

    mobile website builder

    ReplyDelete
  16. The website is looking bit flashy and it catches the visitors eyes. A design is pretty simple .
    regionale stellenbörse

    ReplyDelete
  17. A fascinating discussion is definitely worth comment. I do think that you need to write more techno on this topic, it might not be a taboo matter but typically people do not speak about such subjects. To the next! All the best!!

    ReplyDelete
  18. I have to search sites with relevant information on given topic and provide them to teacher our opinion and the article. i really enjoy to read this
    Ai & Artificial Intelligence Course in Chennai
    PHP Training in Chennai
    Ethical Hacking Course in Chennai Blue Prism Training in Chennai
    UiPath Training in Chennai

    ReplyDelete
  19. it was a wonderful chance to visit this kind of site and I am happy to know. thank you so much for giving us a chance to have this opportunity.. This is the exact information I am been searching for, Thanks for sharing the required infos with the clear update and required points.







    Dot Net Training in Chennai | Dot Net Training in anna nagar | Dot Net Training in omr | Dot Net Training in porur | Dot Net Training in tambaram | Dot Net Training in velachery






    ReplyDelete


  20. Are Yorkies good for first time dog owners?
    teacup yorkie for sale
    The Yorkshire terrier is a great starter dog for those who want a little lap dog. This breed is affectionate towards its owner and may even act protective around strangers.
    The Yorkie has a moderate energy level and only needs basic exercise.

    yorkie puppies for sale good for first time owners?
    yorkie puppies for sale
    It is the ideal pet for people who don't want to deal with pet fur at home or in their cars. This is the ideal pet for first time dog owners, since it trains easily and needs only moderate grooming maintenance. Yorkie poos are good with kids. It will play with them, is energetic and affectionate.

    Are Yorkie hypoallergenic? Yes
    Are Yorkie Poo good for first time owners?
    yorkie for sale
    It is the ideal pet for people who don't want to deal with pet fur at home or in their cars. This is the ideal pet for first time dog owners, since it trains easily and needs only moderate grooming maintenance. Yorkie poos are good with kids. It will play with them, is energetic and affectionate.
    teacup chihuahuas for sale

    Are Yorkie Poos good dogs?
    yorkies for sale

    https://www.newdaypuppies.com/

    ReplyDelete


  21. Are Chihuahua puppies hard to train?
    chihuahua puppies for sale
    Chihuahuas are intelligent, strong-minded dogs that like to do their own thing. This can make them stubborn, earning them a reputation for being hard to train. However, reward-based training methods do appeal to a Chihuahua and there's no reason why they can't be trained to be obedient, just as with any dog

    Chihuahuas Have Fun, Playful Personalities
    teacup chihuahuas for sale
    Though chihuahuas are loyal and affectionate with their owners, they are anything but dull and love to play! However, no two chihuahuas are the same, so if you have a friend with a chihuahua, your pet is likely to be quite different and unique

    What food is bad for Chihuahua?
    teacup chihuahua for sale
    Foods Your Chihuahua Shouldn't Eat
    Alcohol. Alcohol (ethanol) is highly toxic to dogs. ...
    Caffeine. Coffee is one of the world's most popular beverages, with roughly 83% of the United States adult population consuming it on a daily basis. ...
    Chocolate. ...
    Some Fruit Seeds, Pits and Cores. ...
    Garlic. ...
    Grapes and Raisins. ...
    Hops. ...
    Onions.
    chihuahua puppy for sale

    The easiest way to adopt a Chihuahua would be through a rescue that specializes in Chihuahuas. A great place to start would be by starting a breed search on https://www.chihuahuapuppiesforsale1.com/chihuahua-puppies-for-sale-near-me/. The search will show you all the available Chihuahuas in your area.
    chihuahua puppies for sale near me


    ReplyDelete

  22. Is a Yorkie a good family dog?
    yorkie puppies for sale
    Yorkies, like many other Toy breeds, make good pets for people; they're especially good for senior citizens, people with medical issues, and those who may worry about the size and strength of a larger dog. ... They're loving, devoted, and very affectionate: This makes them great personal companions and good family pets.

    Do Yorkshire terriers bark a lot?
    teacup yorkie for sale
    Yorkshire Terriers are little dogs with huge personalities. yorkies for sale With those huge personalities come a fierce territorial bark. Any time your phone rings, someone speaks or knocks on your door, or your doorbell chimes, your Yorkshire Terrier will likely bark. Outside noises aren't even required for barking for some Yorkies. yorkie for sale near me

    How much do Yorkshire terriers cost?
    yorkies puppy for sale
    Typical Yorkie prices range from $1,500 to $3,000, but the cost can fall far below or above that range. Prices will vary based on the puppy's lineage, appearance, health, and the breeder. It's also possible to adopt an older Yorkie for significantly less through a rescue shelter.
    https://www.yorkiespuppiessale.com/


    ReplyDelete

  23. How long does a Yorkie live? 13 – 16 years
    Are Yorkies cuddlers?
    A lover of all things comfortable, the Yorkshire terrier enjoys cuddling with loved ones and snuggling into everything soft and fluffy. And for you, their silky coat isn't too bad for petting. https://www.newdaypuppies.com/

    Adorable Teacup and Toy AKC Yorkie Puppies
    We have adorable Yorkshire Terrier puppies male and female (she is pictured with the bow).The little girl was born on and the male was born on. yorkie teacup for sale Both puppies have started potty training and have had all sets of puppy shots and deworming. They both come with AKC papers.The girl is very petite and has an adorable baby doll face. yorkies for sale near me She is a teacup and will mature to be around just lbs. She is very gentle and easy going She is the princess in our home and loves to be held.The male is full of spunk and is super playful He will mature to be lbs and would make an awesome family dog. He has a gorgeous silky coat and adorable teddy bear face.Both puppies are AKC registered and will come with a health guarantee shot record and sample puppy food. teacup yorkies for sale, teacup yorkie puppies for sale

    Adorable Teacup and Toy AKC Yorkie Puppies is a Female, Male Yorkshire Terrier Puppy for sale in US. Adorable Teacup and Toy AKC Yorkie Puppies by newdaypuppies for Female, Male Yorkshire Terrier Puppies. yorkshire terrier for sale

    ReplyDelete
  24. https://www.chihuahuapuppiesforsale1.com/
    https://www.myppuphouse.com/
    https://www.yorkiespuppiessale.com/
    https://chowchowpuppiessale.com/
    http://www.globalkittens.com/

    ReplyDelete



  25. Is a Yorkie a good family dog?
    Yorkies, like many other Toy breeds, make good pets for people; they're especially good for senior citizens, people with medical issues, and those who may worry about the size and strength of a larger dog. ... They're loving, devoted, and very affectionate: This makes them great personal companions and good family pets.

    Do Yorkshire terriers bark a lot?
    yorkies for sale
    Yorkshire Terriers are little dogs with huge personalities. teacup yorkies for sale With those huge personalities come a fierce territorial bark. Any time your phone rings, someone speaks or knocks on your door, or your doorbell chimes, your Yorkshire Terrier will likely bark. Outside noises aren't even required for barking for some Yorkies. yorkie puppies for sale

    How much do Yorkshire terriers cost?
    yorkie for sale near me
    Typical Yorkie prices range from $1,500 to $3,000, but the cost can fall far below or above that range. Prices will vary based on the puppy's lineage, appearance, health, and the breeder. It's also possible to adopt an older Yorkie for significantly less through a rescue shelter. yorkie for sale

    ReplyDelete

  26. Are Yorkies good for first time dog owners?
    yorkshire terrier for sale
    The Yorkshire terrier is a great starter dog for those who want a little lap dog. This breed is affectionate towards its owner and may even act protective around strangers. teacup yorkie puppies for sale The Yorkie has a moderate energy level and only needs basic exercise.

    Are Yorkie Poo good for first time owners?
    tea cup yorkie puppy for sale
    It is the ideal pet for people who don't want to deal with pet fur at home or in their cars. This is the ideal pet for first time dog owners, since it trains easily and needs only moderate grooming maintenance. Yorkie poos are good with kids. It will play with them, is energetic and affectionate.

    Are Yorkie hypoallergenic? Yes
    yorkshire terrier for sale near me
    How much does a Yorkie Poo puppy cost?
    Yorkie Poo puppies range in price from $1,000 to $3,500, depending on the puppy's coloring and the breeder.

    Are Yorkie Poos good dogs?
    yorkie puppies for sale
    The Yorkipoo is a gentle and loving dog who can do well with children. He's not recommended for homes with very young children, since he can be easily injured when improperly handled. A Yorkipoo can make an excellent companion for an older, more considerate child.

    ReplyDelete

  27. Do Yorkshire Terriers bite?
    Puppies bite beginning at a very young age. They learn this behavior while still with their littermates, long before you bring your Yorkie puppy into your home. yorkshire puppies for sale If the biting can be corrected while a Yorkie is still a puppy, training works best. ... This will be very similar to when a puppy yelps in pain. teacup chihuahuas for sale

    What are Teacup Yorkies?
    Teacup Yorkie is a smaller version of the same pure breed Yorkie, also known as Toy Yorkie or Micro Yorkshire Terrier. It's a tiny dog breed at about 5 to 7 inches tall, weighing between 2 to 4 pounds. The average lifespan of the Teacup Yorkie is around 12 years. yorkie terrier for sale

    Why do they cut Yorkies tails off?
    https://www.newdaypuppies.com/teacup-yorkie-puppies-for-sale/
    The main reason that Yorkie tails are docked are for aesthetic purposes. The natural tail is long and sticks up beyond the height of the head. A docked Yorkie has a tail that sticks straight up below the level of the head, which creates clean lines when the hair is worn at show length. yorkie puppies for sale

    ReplyDelete

  28. Are Yorkies high maintenance?
    https://www.yorkiespuppiessale.com/
    The spunky Yorkshire Terrier has a lot going for him, but his beautiful coat is high-maintenance, even if clipped short. yorkie puppy for sale near me A Yorkie with a long coat requires daily brushing and weekly baths. ... Yorkies for sale near me don't shed much compared with some other dogs, but they aren't hypoallergenic.

    Are Yorkies hard to train?
    Are Yorkies easy to train? yorkie puppies for sale are not the easiest breed to train. It's not because they aren't smart; they are quite an intelligent breed. But they tend to be confident, curious, and a bit stubborn—all of which can make training more difficult.

    Are Yorkies smart?
    So, are Yorkies smart? Yorkshire Terriers are highly intelligent dogs. According to canine psychologist Stanley Coren, are “above average” intelligent dogs. yorkies puppy for sale In fact, they're ranked the 34th smartest dog breed out of 138 qualifying breeds.


    ReplyDelete