Scott Hanselman

Penny Pinching in the Cloud: Running and Managing LOTS of Web Apps on a single Azure App Service

February 17, '17 Comments [24] Posted in Azure | nodejs
Sponsored By

I've blogged before about "penny pinching in the cloud." I'll update that series for 2017 soon, but the underlying concepts still apply. Many if you are still using bigger virtual machines than are needed when doing IaaS (Infrastructure as a Service) or when doing PaaS (Platform as a Service) folks are doing "one website per App Service." That's super expensive.

Remember that you can fit as many web applications as memory and CPU will into an Azure App Service Plan. An "App Service Plan" in Azure is effectively the Virtual Machine under your Web Apps. You don't need to think about it as it's totally managed and hidden - but - if you choose think about it you'll be able to squeeze more out of it and you'll pay less.

For example, I have 20 web applications running in a plan I named "DefaultServerFarm." It's a Small Standard Plan (S1) and I pay about $70 a month. Some folks use a Basic (B1) plan if they don't need to scale out and that's about $50 a month. Both B1 and S1 support "unlimited" web apps within them, to the limits of memory. That's what allows me to run 20 modest (but real) sites on the one plan and that's what makes it a good deal from a pricing perspective for me.

I logged in to the Azure Portal recently and noticed the CPU percentage on my plan was higher than usual and higher than I'd like.

Why is that web app using so much CPU?

That's the CPU of the machine "under" my 20 sites. I can click here on my App Service Plan's "blade" to see the underlying sites, or just click "Apps" in the blade menu.

Running 20 apps in a Single Azure App Service

However, when I'm looking at an app that lives within my plan, there's two super powerful menu items to check out. One is  called "Metrics per instance (Apps)" and one is "Metrics per instance (App Service)." Click the latter option. For many of you it's going to become your favorite area in the Azure Portal. It was a game changer for me as it gave me the internal insight I needed to make sure I can get maximum density in my plan (thereby saving the most money).

Metrics per Instance - App Service Plan

I click here and see "Sites in App Service Plan."

20 sites in a single plan

I can see that over the last few days my CPU has been going up and up...

The CPU is going up and up over a few days

I can see by site:

A graph showing ALL 20 sites and their CPU

So now I can filter by site and I see that it's ONE site that's going nuts.

One site is using all the CPU

I can then dig in, go to the main CPU charge and see exactly when it started:

The site is using 2.12 days of CPU

I can change the scale

It started on Feb 11th

I had a Web Job stuck in a loop. I restarted and will be monitoring but for now, I'm in a much better place for this one app.

Now it's calming down

Now if I check the App Service Plan itself, I can see everything has calmed down.

Things have calmed down after the one rogue site was restarted

The point here is that even though it's "Platform as a Service" and we want a layer of abstraction, at no point are things HIDDEN from us. If you want to see the hardware, you can. If you want to see the process tree, you can. A good reminder.


Sponsor: Excited about the future in ASP.NET? The folks at Progress held an awesome webinar which gives a 360⁰ view of the new ASP.NET Core and how it compares to WebForms and MVC. Watch it now on demand!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb
Friday, 17 February 2017 23:18:58 UTC
When I first started using Web Apps took me a while to realise I could add more than one Web App to the same plan for no extra cost. Something always worth repeating.
Saturday, 18 February 2017 00:33:41 UTC
Of course today App Hosting Plans are so much more; you can run Websites, docker containers, Azure Functions, Mobile Apps, Api Apps, Logic apps in any language all together in a high density way and with easy automated scale out.
Saturday, 18 February 2017 13:36:09 UTC
Such a great article. For those not yet caffinated (or in the tub), super breifky - whats the process to add a new app in this model? I can't picture an "add another web app & domain" button in the blade.
Saturday, 18 February 2017 15:05:05 UTC
Very good info thanks.
Paul Stanley
Saturday, 18 February 2017 17:45:28 UTC
"Running and Managing LOTS of Web Apps on a single Azure App Service"

You're talking about running lots of Web Apps (App Services) instead of a single App Service *Plan*, not within a single App Service, right? I think the title is a bit confusing.
Saturday, 18 February 2017 17:52:02 UTC
Meh, kettle/pot. My comment is a bit confusing with that typo in there...

You're talking about running lots of Web Apps (App Services) within a single App Service *Plan*, not within a single App Service, right? I think the title is a bit confusing.
Saturday, 18 February 2017 21:02:59 UTC
Agree with Ben.

It's unclear that you're paying for the size and number of VM instances, which App Service Plan includes. Where apps (Web Apps, Mobile Apps, Logical App, API Apps) are just IIS web sites (if based on Windows).

If I scale App Service Plan out by adding more instances, I presume it adds additional VM instances, which I should pay for. Right?

What's about slots? If I add an additional slot, will my apps still sitting on the same VM instance, but with different prefix/postfix in IIS?
Sunday, 19 February 2017 10:51:20 UTC
Looks like only .Net apps appear in these charts? I have a Wordpress site hosted in my app service plan along with an ASP.NET app, but only metrics for the ASP.NET site appear (which presumably makes sense, if it is using performance counters).
James Webster
Sunday, 19 February 2017 11:42:06 UTC
What would be nice is if they removed the lack of slots from the Basic plan - means I can have the same development process and then just scale out as needed.

Without this, you have to create individual sites contoso-dev, contoso-devint, contoso-test

The resource consumption is the same anyway so it sounds like a marketing rather than technical distinction.
Monday, 20 February 2017 06:45:22 UTC
James - No, my app that was misbehaving was node. I have .NET apps, PHP apps, node apps, all in the same App Service.
Scott Hanselman
Monday, 20 February 2017 08:05:35 UTC
As a newbie to Azure the problem is I do need to think about it. With a VM with RDP I can set-up IIS/SQL Server/whatever. With Azure it's all abstracts and units which is a massive mind shift if you some of the infrastructure stuff.

For example, when you want to change a web.config, normally you'd just remote into the server change it job done. However with Azure you need to add a plug (not sure if it's referred to that) in order to access that kind of stuff.

And charging for units used - is it any wonder people get confused and over or under utilize, what the hell is a unit, it's the same difference as when Microsoft used to charge in MS points on the Xbox store vs. actual money - you never really knew what you were spending without thinking about it.
Peter
Monday, 20 February 2017 14:21:45 UTC
What about database? Surely those 20 websites need to connect to database somewhere, are you using Azure SQL Database? That would dramatically add up the cost, no?
rosdi
Monday, 20 February 2017 14:53:25 UTC
Great read thanks! Would there ever be a free hour to review a server setup, app and docker stuffs? Kinda an all-in-one review for use noobies with Azure? You recommend Azure for .NET vs. Rackspace or other?
Chris
Monday, 20 February 2017 15:13:41 UTC
I've been under a rock and have not kept up with Azure. I assume you could've created an alert of some sort to text or email you about the unusual spike in usage; Rather than "[logging] in to the Azure Portal recently and [noticing] the CPU percentage on my plan was higher than usual and higher than I'd like." How much did 6 days of increased CPU cost you?
Martin Van Den Bossche
Monday, 20 February 2017 15:42:54 UTC
Peter, you can edit files like web.config in an Azure App Service using the App Service Editor (under the "Development Tools" section of the App Service blade). No plug-in required. It gives you a VS Code-esque interface to edit files in the directory.
Monday, 20 February 2017 15:52:11 UTC
Standard App Service Plan pricing is based on the VM size and how many instances you've scaled to. Higher CPU consumption does not cost extra money.
Tuesday, 21 February 2017 08:19:56 UTC
@Mikey Cooper - ah - I get confused easily between all the different bits because I don't have to deal with it much at present.

My point still stands though, if you know some infrastructure stuff - or you know you're a dev so you can install SQL Server/IIS and the like it's a big mind shift to have all the tools taken away from you and have to do things a completely different way that takes if any thing longer.

The ability to scale up/out is the benefit I know but man so confusing.
Peter
Tuesday, 21 February 2017 17:27:57 UTC
Is there any way to set an alert on those values? Can you set up an alert on your billing. "Hey, your bill is going to be over X this month if your usage stays constant!"

Wednesday, 22 February 2017 08:26:15 UTC
Azure is excellent. In November 2016 I decommissioned a number of physical servers, running several vm's and migrated my entire hosting platform into the Cloud. I had been eagily awaiting MS to open their UK Azure regions and for Anycast DNS (paas) to come out of preview, the migration went without a hitch.

And then... within 3 weeks of me completing the migration I received an email stating that Microsoft were hiking Azure prices by 21%. This was a massive hit for me and totally unexpected. I get the whole brexit bandwagon thing but this has now forced me to start looking at AWS who opened their local UK regions in December 2016. Shame as I was starting to fall in love with the Azure portal.
Wednesday, 22 February 2017 14:50:56 UTC
Whatsapp plus is the latest app to communicate with others. Get whatsapp plus apk to chat with your friends and family, share your favorite stuff with them for free. check it for WhatsApp plus apk 2017.
Sara
Thursday, 23 February 2017 09:35:28 UTC
One thing to note here: All apps need to be in the same resource group (and the same app service plan of course) in order to see all of them on one chart. If apps are in different resource groups, you will not see them on one chart even though they reside in same app service plan.
Jan Z
Friday, 24 February 2017 10:02:31 UTC
Hi Scott

Thanks for your excellent post, it just came at the same time im looking into moving my sites into Azure Web App.

Could you please explain how i can have multiple Web App's running each on it's own domain inside a
'Standard: 1 Small' Web App.

Thanks a lot
Søren Reinke
Saturday, 25 February 2017 07:34:09 UTC
Hi Scott

Found the solution :-)
Søren Reinke
Monday, 27 February 2017 21:34:08 UTC
Another nice addon is Let's Encrypt extension which enables free SSL certs. It's a little tricky setting up but definitely a $ money saver.
Matt G
Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.