How I Run Two-Dozen Apps & Websites on a $25 Virtual Machine

Author

Brandon Bruno

Published

Tags

It was 1998 when I learned how to FTP into the 1MB file share provided by our dial-up internet provider, WCNET (long gone, by the way!). I've been publishing on the web ever since.

Years later I moved through several new servers as my developer skills grew:

  • 2009: I built a LAMP stack on a self-hosted tower in the corner of my living room
  • 2013: As a .NET developer, I moved to a self-hosted Windows machine
  • 2016: I finally joined the cloud and chose an Azure virtual machine for web hosting

Moving to Azure was a Very Big Deal. I was suddently freed from the responsibilities of having to maintain hardware, ensure uptime, and manage risks (internet outages, theft, ensuring backups) - you know, all the things enterprises don't want to deal with but at a microscopic scale.

But there's one little detail that bothers me to this day: money. How much will cloud hosting cost me in the long run?

As it turns out, not too much! I'm currently paying around $25 USD / month to run over 13 static sites, blogs, and web applications - including the databases and services needed to support them.

So how do I stretch my money?

Setting Expectations

First, I'm very realistic about the reach of my websites and web apps. Most of my websites are static, low-traffic sites (e.g. BrandonBruno.com). My other web apps are similiarly low-traffic (no one is scrambling to use my dynamic forms product, but it was fun to build!).

Sitecore Spark is the busiest site I run - averaging around 8,000 pageviews per month - without any bandwidth or performance issues.

text

Not pictured: another nine console applications that run on schedules to handle routine server and database tasks to support several applications.

Despite modest expectations, my goal is simple: run as many websites and applications well-enough on the lowest-possible hardware configuration.

The Configuration

Given my modest hosting needs, I don't need a beefy VM. I'm currently running a Standard B2s Azure VM with the following resources:

  • 2 vCPUs
  • 4 GB RAM
  • 128 GB SSD storage

2 virtual CPUs and 4 GB of memory doesn't sound like a beefy web server, but that's the ultimate lesson: you probably need less hardware than you think!

Protecting AppPools

I'm protective of those precious resources - especially memory - by carefully managing AppPools in IIS:

  • all static sites run on one AppPool
  • the top-three highest traffic sites get persistent AppPools that rarely recycle
  • the lowest-traffic AppPools shut down every 24 or 48 hours (and because they are simple apps, they spin back up very quickly)

Databases

SQL Server Express is my database of choice, but it's sledgehammer where a rubber mallet would do for most of my applications. As I port my older web applications from .NET Framework to .NET 6/7/8, I'm moving to SQLite databases, which provide major benefits:

  • extremely simple to deploy
  • easy to backup (script a copy to another location)
  • very performant for reads (i.e. blog content delivery)
  • isn't a separate process that consumes CPU and memory

As long as I'm hosting read-heavy, content-based websites and low-user web apps, SQLite is the perfect database for a low-cost server.

Cost Breakdown

In 2023 this VM runs about $42 USD / month, but that's not cheap enough for me.

Azure offers reserved VM instances, which I take advantage of by paying an upfront annual amount (roughly $150), then paying for some usage beyond that reserved block. That monthly usage is about $12 USD (although it's occassionally much less).

All in all, that balances out to about $25 / month to run a simple Azure VM that hosts all my application needs. Part of that monthly cost is a Windows license, so I could reduce it even further if I brought my own key.