Where to host .NET Core applications?
When I first started programming, I was eager to build an application and show it to the whole world. I could write some simple web sites, but I have no idea what a hosting is. In this post I want to help some new programmers to showcase their ideas and applications. A hosting is not necessarily something expensive. On the contrary if it is a brand-new site you probably do not want to go big in the beginning. Here are some ideas on where upi might host your apps:
If you have a PC that is lying around you can always give it a new life to host your applications. This is the cheapest solution that we will discuss in this blog post. Put a server inside, make a reverse proxy to Kestrel and you are good to go.
How good is this approach? Not good if you do not know what you are doing. You basically have to support it. Update the OS, update the software, check security logs, keep the machine alive etc. The list is endless, so this approach is not very beginner friendly.
One of the obvious candidates is the cloud. Azure takes a huge burden out of your shoulders. Microsoft is responsible for keeping the server and operating system secure, performant and available. And all you must do, is to write code and deploy it. Some of the services that Azure provides and used by most small applications are:
Web App - a platform to build an App in Azure without having to deploy, configure and maintain your own Azure VM’s. You can configure some of the security settings and runtime versions of the Web App, but you don’t have to do that in most cases.
MSSQL - SQL Server that is hosted in Azure. You can use SQL Server Management Studio to connect to it. Keep in mind that for a simple application you probably want to start with the lowest tier
Application Insights - Monitor your applications with ease using Application Insights. You can add it to your web app with a couple of clicks inside Visual Studio. You can also query the collected data and make some analysis
Redis - In-memory data store which is also hosted in Azure. Really fast reading and writing speed. Often used for caching.
All of the above services are maintained by Microsoft which takes a lot of burden out of the developer’s hands. You do not have to worry about the security, updates, hardening…etc. Just write code and do some basic configurations. Life is beautiful.
The question is how much all this luxury costs?
If you host a basic Web App that does not have anything external (like a database) it is free. Yes really. What is the catch then? Well you cannot run containers here…bummer. If you need containers you should upgrade to Basic Tier. So how much does that costs? It is complex since it is based on your region, data center and there are a bunch of other stuff. I personally do not know a way to calculate how much a web application that uses SQL Server, Application Insights and Redis can cost you. There are just too many variables.
AWS free tier
If you are not a fan of Azure, you can always choose AWS which offers a free tier.
One of the simplest ways to host a .NET Core application is to just create a Micro EC2 instance which is eligible for free tier. EC2 stands for Elastic Cloud Computing which is basically a Virtual Machine. Let me warn you beforehand that AWS has some weird names for their services. Once you have the virtual machine you can install a Docker and host your application there or just install .NET Core Runtime inside and make a reverse proxy to Kestrel. It’s a virtual machine and you are the boss.
Be very very careful, AWS can still charge you if you do not know what you are doing and let’s be honest, you don’t. There are horror stories online about people that got burned by free tier. Do your research properly because AWS does not warn you when you exceed some quotas, or you are using a service that is not eligible for free tier. They will charge you without any question.
Digital Ocean and Vultr
Pretty affordable developer cloud. Digital Ocean gives you the option to start small and grow as you go. They offer so called Droplets which are virtual machines available in multiple configurations of CPU, memory and SSD. The cheapest droplets are:
They charge you $0.007 per hour for a droplet even if this droplet is not currently online so keep that in mind. If you do not want to get charged you should delete the Droplet. Also, your monthly charge per basic droplet cannot get above $5.
Most importantly Digital Ocean has out of the box support for Docker and a great firewall. Another good thing is they have amazing documentation for pretty much any scenario that you can think of.
Another cloud provider is Vultr
I personally never used Vultr so I cannot comment based on experience. Here is what they provide so you can compare them with Digital Ocean and make an informative decision:
My personal choice of hosting .NET Core applications. Contabo is a German hosting provider which offers computing power, storage and networking for hosting whether for business or private applications. I have been using Contabo for couple of months now. I cannot give a detailed review yet but so far, I am loving it. For only €5 you get:
|8GB||4vCPU||Unlimited||200GB||Linux distro of choice||€4.99|
|16GB||6vCPU||Unlimited||400GB||Linux distro of choice||€8.99|
Which is way more than Digital Ocean or Vultr for similar price range. However, when you register the first time you have to pay 10€ one-time fee. Any subsequent months will be the standard price that you choose. During the configuration of your VPC you have the option to choose between Linux distros. You can also choose windows but keep in mind that it is paid additionally.
If you are in Europe, I think the best option is clearly Contabo. For only 5 bucks you get a pretty powerful VPS which you can host your .NET Core applications. Put a docker inside and you can run multiple apps. This machine can handle it without a problem.
How do you host your applications? Share with me in the comment section.