.NET Microservices #1 --> Containers, Architecture decisions and Scaling

Containers, Architecture decisions and Scaling

Microservice-based applications and using containers to managing them

Microservices architecture is an approach for distributed mission-critical applications. It is build on a collection services that can be developed, tested, deployed and versioned independently.

What are containers?

Containerization is a software development approach in which an application, its dependencies and its configuration are packaged together as a container image.


Docker is becoming the de facto standard in the container industry.

Why containers?

By using containers enterprises benefit from

  • saving costs, solve deployments problems and Improving DevOps

Containers offer the benefits of

  • isolation
  • portability
  • agility
  • scalability

Containerization allows scalability. Instantiating an image is similar to instantiating a process like a service or web application. Instantiating same image in a different host server or VM for each container is recommended for better reliability.

Application Isolation and container host

Containers isolate applications from each other and run on top of container host that intern runs on the OS. As a result containers have a significantly smaller footprint than virtual machine images


Architecture patterns

Container Lifecycle: long-lived and short-lived

In the container model, a container image instance represents a single process. A process can scale to make it long-lived or batch the process making it short-lived. Container process lifetime is controlled to represent long-running processes like web servers or can represent short-lived processes like batch jobs. In Azure these are called Web Jobs.

if the process fails, the container ends and the orchestrator takes over. if the orchestrator was configured to keep a number of instances running and one fails, the orchestrator will create another container instance to replaced the failed process.

There can be one entry point per container but if you want to run multiple processes in a single container you could use a script within container that launches as many programs needed.

How to containerize and scale large applications?

Method1: Monolithic application in a single container

You might want to deploy a single, monolithic application as a container. The application itself might not be internally monolithic, but structed as several libraries, components and in layers.

To manage this, you deploy a single container to represent the application, To increase capacity you added more copies with a load balancer in front. A monolithic containerized application has most of its functionality with in a single container.


  • Managing a single container for whole application is easy


  • violates the container principle " a container does one thing, and does it in one process"
  • Scale the application results in scaling all the components with even though it is not required
  • Changing a single component result in complete retesting of the entire application and redeployment of all instances

Method2: Separate containers for each component of Monolithic application

You might want to deploy components of the monolithic application into separate container fore each and hosted in a VM. To scale only the needed components create the container image instance into a new VM scale set.


  • Lowly coupled design
  • Scale only the required components
  • retesting only the components that are changed


  • Managing various scale sets and VMs.

Container deployments

  • Using VMS: Deploying containerized applications into a dedicated VMs and scaling them using Azure VM scale sets.
  • Using Azure App Service: Deploying containerized applications with out the need of VMs. Azure App Services can run single instances of Docker containers, simplifying deployment and scaling.

Containers over VMs

  • Scaling containers instances is faster and easier than deploying additional VMs.
  • Deploying docker image is faster and network efficient, typically start in seconds.
  • Because containers are immutable by design, you never need to worry about corrupted VMs.
  • Container orchestration manages lifecycle of each container instances allowing application modularity making it possible to design microservice-based applications

No Comments Yet