I think I have simple, every day requirements
- Host two ASP.NET 4.5 applications. Lets call them ComicSyndicate and Erbsenzähler
- Run both under my own domains
- Use SQL Server as data store, but only two small databases (less than 50 MB in size each)
- Both applications have one ore more small EXEs that do some background work every few hours
- Both applications have small memory and CPU requirements
- Both are just side-projects of mine. I don’t earn any money with them. I don’t want to spend a lot on them, too
„This is a perfect fit for Azure Web apps“, I say to myself. I’ve been playing around with Azure for a couple of years, but never for „production“. And I never had to spend any real money on it, because my playing-around all ran on my employers free MSDN credits.
For those who are not familiar with Azure Web apps
Azure Web apps is a PaaS service for hosting ASP.NET / PHP / Java / Node.js web applications. You don’t have to take care of any OS or web server, just deploy your application and Azure runs it, including options to scale it up if needed. It also supports so called WebJobs, which are background tasks (scripts or EXEs). Azure Web apps can be deployed via FTP, WebDeploy or directly from GitHub source code.
In addition, Azure offers a PaaS edition of SQL Server (actually not really SQL Server, but something so similar that the differences don’t matter to me).
By the way, Azure Web apps were called „Azure Websites“ until a few weeks ago.
My Azure setup and my problems with it
Azure Web apps offer a free tier, which is great for playing around with it. But as soon as you want to use your own domain, you will be charged. The smallest tier Shared only costs a few Euros a month, which, in my opinion, is quite reasonable.
There is no free tier for SQL Server, but again, the smallest tier Basic is very affordable, even for some side-project.
So I set everything up on Azure.
One big plus of Azure is its deep integration within Visual Studio. Creating a new Web app and deploying your project takes just a few clicks. But I use GitHub and AppVeyor, so that is of no big use to me. Luckily, Web apps support WebDeploy, so all I have to do is to create the Web app via the Azure management portal and to configure the deployment in AppVeyor, wait for the next build (the free tier of AppVeyor always takes a few minutes before a build starts) and voilá – my Web apps are up and running.
And then the problems start.
The smallest tier of the PaaS SQL Server on Azure is apparently quite limited. Less in the way of features, but more in the way of performance. I cache heavily in my applications (mostly good old, simple ASP.NET Output Cache) and in general think thrice about every call to the database I make. But still, the database server can’t handle the load (about 60 requests per minute, but most of them cached).
It takes me a while to find the cause of all the timeout error messages in my application („The wait operation timed out“), because only Azures new preview management portal displays the necessary information. Well, one of my two databases is at almost 100% resource utilization (Azure calls them DTUs). I try to further optimize my code, but to no avail. I have to switch to a higher, more expensive SQL Server tier. At least that solves my database issues.
Then suddenly the ComicSyndicate application is down and returns only a blue Azure error message („The website has been stopped“). Again, it takes me a while to identify the cause, because this time only Azures old management portal shows me the information. But it seems that running ComicSyndicate requires more than the allowed 512 MB of RAM. I remove a few less vital components (NewRelic and AppInsights performance monitoring among them) and that brings ComicSyndicate down to about 450 MB of RAM. But every time I do a new deploy, it goes over the limit again and I have to wait 30 minutes to let the limit reset itself.
The thing is: On my local machine the application only takes about 150 – 300 MB of RAM (I looked at the TaskManager and the w3wp-Process), even when under load (only artificial load, of course). I have no idea where the high RAM utilization on Azure comes from, maybe parts of the OS or IIS count towards it, too?
Others seem to have similar problems. And it definitely is a serious one for me. I move my background jobs into a different Web app (one on the free tier) to lower RAM utilization. This helps a little, but still is a big hassle and complicates my deployment. It even seems to me that the WebJobs require RAM even if they are not running, but I’m not sure about that. Of course, these problems will go away if I switch to a higher tier, but it will be far more expensive, too.
One of my background jobs uses PhantomJS (via Selenium webdriver) for some website scraping. Internally, the webdriver starts the PhantomJS EXE and uses HTTP/REST over some special port to communicate with it. This absolutely doesn’t work inside an Azure WebJob (I posted a question on StackOverflow), although I’m not sure if launching another EXE from a WebJob is blocked or just the network communication between WebJob and PhantomJS. I think this limitation is „by design“ and a problem I will not be able to solve with WebJobs. I guess I need my own VM and OS for this kind of „advanced background job“. But that kind of goes against the entire idea why I want PaaS in the first place.
To summarize my problems with Azure
- The smallest SQL Server tier provides only a very basic level of performance. More money solves this problem.
- The smallest Web app tier provides only limited RAM resources and those are not enough even for my fairly basic application. (A lot) more money would have solved this problem.
- WebJobs are limited in what they are allowed to do.
- Different set of features on the two very different Azure management portal. This will, I guess, get better as soon as the new portal is out of preview.
What I like about Azure Web apps
- There are very affordable or even free tiers for most services.
- Deep integration into Visual Studio, but Visual Studio is no requirement. In general, deployment is very easy, especially „Deploy from GitHub“ is awesome.
- It’s dead-easy to scale the PaaS (either manually or automatically). Although I probably will never need it for my tiny side-projects.
What it costs
- 2 Web Apps (Shared): 14.41 € / M
- 1 SQL Server database (Standard): 11,18 € / M
- 1 SQL Server database (Basic): 3,73 € / M
I don’t count any storage or bandwidth costs, because those are negligible. All in all my scenario costs about 30 € a month. Not included is the VM I will need to run my „special“ background task, the smallest Windows VM on Azure is about 10 € a month.
I’m not happy. So I start looking for alternatives.
In the second part of this post I write about my move to AWS and my problems there. Because there are always problems, aren’t there?