Containers and microservices enable developers to build and manage self-healing microservice-based applications more easily. While the two terms aren’t the same thing, in reality, containers and microservices are often used in the same sentence.
Microservices contain everything from the operating system, platform, framework, runtime and dependencies, packaged as one unit of execution. Containers encapsulate discrete components of application logic provisioned only with the minimal resources needed to do their job
So, what are microservices? A microservices architecture splits your application into multiple services that perform fine-grained functions and are part of your application as a whole. Each of your microservices will have a different logical function for your application.
Traditional applications have monolithic architectures where all your application’s components and functions are in a single instance; microservices break apart monolithic applications into smaller parts.
Technically speaking, a container is just a process spawned from an executable file, running on a Linux machine, which has some restrictions applied to it, for example:
- A container is not allowed to “see” all of the filesystem, it can only access a designated part of it.
- A container is not allowed to use all of the CPU or RAM.
- A container is restricted in how it can use the network.
Historically, modern operating systems have always imposed restrictions on processes, for example every Linux process runs with privileges of a system user, but the containerization technology has introduced more possible restrictions and made them more flexible.
A container is a useful resource allocation and sharing technology. It’s something devops people get excited about. A microservice is a software design pattern. It’s something developers get excited about.
They are related, but do not require each other. You can have a monolith deployed as a container, or you can have an unrestricted, non-containerized microservice.
Benefits of Microservices
- easier automated testing;
- rapid and flexible deployment models; and
- higher overall resiliency.
Drawbacks of Microservices
- the need for more careful planning;
- higher R&D investment up front; and
- the temptation of over-engineering.
Let’s compare some of the most popular tools for containerized microservices in detail:
- First large-scale, open-source containerization solution.
- Built-in security: Containerizing an app with Docker automatically reduces the chances of an app outside the container running remote code. This offers built-in application security without needing to code any audits.
- Scalability: After running a web-based microservice in a docker container, the application can run anywhere. Users can access the microservice via their smartphones, tablets, laptops, or PCs. This significantly reduces your deployment and scalability challenges.
- Reliable deployment infrastructure: Docker’s hard-coded deployment infrastructure with version control ensures that everyone on your development team stays on the same page.
Kubernetes is another name synonymous with containerization. It is a “container orchestration” tool that helps developers run and support containers in production. The open-source container workload platform allows you to manage a group of containerized microservices as a “cluster.” Within a Kubernetes cluster, you can distribute available CPU and memory resources according to the requirements of each containerized service. You can also move containers to different virtual hosts according to their load.
Swarm is a container orchestration tool native to the Docker ecosystem. Swarm is a simpler solution for teams that don’t require the advanced features of Kubernetes. Because of its simplicity, Swarm facilitates faster container deployment in response to new demands.
Mesos is an open-source container orchestration tool similar to Kubernetes. Unlike Kubernetes, Mesos orchestrates other types of applications in addition to containerized ones. That’s why Mesos calls its commercial product DC/OS (Data Center Operational System). As Dorothy Norris on Stratoscale points out, “Mesos understands that …we should use the best tools for each particular situation.”
At AnAr, we analyze the most popular tools for launching and orchestrating containerized microservices according to business needs. Contact us for more details.