Microservices: Picking the .NET Framework for your containerized applications.
The objective of this blog post is to explain the factors that should be considered when picking a framework for a .net application that you intend to deploy in containerized fashion.
Generally, .Net Core is the preferred option when building applications that were intended to be deployed in containers due to the fact that .Net Core is built using modular architecture (.net core app images contains only the dependencies it requires to run). .NET Core apps are packaged using Windows Nano Server which is a far smaller compared to the OS required by the standard .NET runtime (Windows Server Core) therefore producing lighter images (end product of building containerized application).
On the image above, you will see an image built for .Net Core app that prompts "Hello World". Please take note of the size of the image (251 MB) as it would be critical to demonstrating the difference of the two frameworks.Download Demo Apps from GITHUB
When to pick .NET Core?
Polyglots are applications built using different platforms (EG. Combination of Java and .Net processes in a SOA app). Basically, .Net Core can be used to build applications that run on both Linux and Windows.
Your application's architecture is Microservices
Containers are perfect for deploying Microservices because they allow the complete isolation of services. This basically enables the use of different platforms and dependencies per service without the nasty side-effects of hosting this applications together.
You intend to save on hardware cost
Images built using .NET Core have small footprints (RAM and Storage) which enables us to host different containers inside a VM or Physical machine.
You need fast app start up
Since .NET Core apps ship with things it only depends on, application can quickly startup.
You intend to build Green-Field applications
.NET core is the most advised framework to be used for building green-field applications (Fresh Projects). Since it is designed for the future of .NET development.
You intend to build high density and scalable applications.
Since containerized applications are easy to scale using container orchestrators like Docker Swarm, Kubernetes, DC OS and Mesosphere; .NET core is the perfect framework
.Net Framework is the preferred option when you intend to containerize an existing application or utilize things that deeply depend on Windows API. It is always advised to pick .NET Core over .NET framework because of the Huge image that .NET framework images produces. NOTE: Huge image size corresponds to higher cost of hosting in cloud based docker image repositories. It also means larger cost for compute power to run the containerized app.
On the image above, you will see an image built for .Net Framework app that prompts "Hello World". It is quite noticeable that this image is way larger (10.4GB) than the image built using .Net Core.
When to pick .NET Framework over .Net Core?
Migrate an application that is difficult to port in .Net Core
If migrating an application from .NET Framework to .Net Core is associated with high risk over produced value, it is highly suggested to keep the existing app and host it on containers.
Your application depends on a binary that doesn't have a .Net Core counterpart.
Since .NET Core is still young and hot, there are still binaries that don't have a .NET core counterpart. A perfect example of this is proprietary or internal frameworks of companies.
Usage of .Net technologies not available for .Net Core
As of November 2017, ASP.net Web Forms, WCF services and Workflow related services are still not supported.
- Microservices: Why choose Containers over Virtual Machines.
- Microservices: Issues Associated with RDBMS and Strong Data Consistency