Breaking applications into smaller coupled components like microservices, and running each of those components in containers often go hand in hand. These modern application architecture principles have allowed many businesses and software projects to make regular and rapid changes to running software and scale them to suit changes in demand and approach. In this article, we breakdown what a container is, and the direct benefits they bring to your developer teams and business.
You can think of containers as a way to virtualize multiple machines on top of one physical machine. The concept of virtualization is nothing new, and business has used virtual machines for decades to roll out applications and entire systems to users. There are some parallels between the two technologies, but it’s the differences between them that bring the benefits.
Virtual machines abstract aspects of a “real machine” for each virtual machine you create. This means that in addition to the hardware and host operating system (OS), each virtual machine simulates hardware, holds a guest OS, libraries, dependencies, and applications. If you rapidly create a lot of virtual machines, this creates significant overhead for disk space and memory for OS resources that are often duplicated.
Containers take a different approach, utilizing features built into every modern operating system to remove the need to virtualize an entire operating system for each container and focus on creating the unique parts that every application needs.
When you use containers, you define an “image” (or choose from thousands created by others), which runs as an instance (the actual “container”) on top of a “runtime” that runs in a host operating system. The runtime handles each running container, the applications inside those containers, and the interactions between those applications.
Docker popularized the container concept with their spec and tooling, but was not the first or the last, with other options such as rkt, lxd, OpenVz, and containerd. To help users have a consistent experience between the different options, the Open Container Initiative (a Linux Foundation project) maintains standardized specifications for the runtime and images, meaning that you can transfer containers from one to another with minimal change.
Containers allow developers to create consistent and recreatable environments that are isolated from each other and can include dependencies.
As the container image defines the base dependencies, there is a high level of guarantee that what runs on a developer machine, also runs in a variety of production environments, and runs on any host operating system in the same way. This leads to development teams spending less time debugging and fixing personal infrastructure issues, and more time working on improving applications.
Containers don’t run in complete isolation, as different services communicate with each other through API calls, service meshes and other ways of discovering each other. But containers do isolate critical resources such as the container’s access to the underlying CPU, memory, storage, and network resources between each container. This reduces the chances of individual containers consuming too many resources, but also prevents potential security issues.
Container-based applications, and the broader microservices pattern allow different teams to work on different components without getting in each others way too much. Using containers allows you to define the infrastructure your applications run on as code, which means that different teams can work on the application and infrastructure code more collaboratively.
Thanks to their low overheads and boot speed, containers introduce the ability to adapt applications in ways not possible before. Using basic scripts or complex “orchestrators” you can quickly recover crashed application components, add new instances to meet increased demand, or perform rolling upgrades to update application or dependency versions without any downtime. Developers can also experiment with new languages and patterns in application components without needing to bring an entire application down.
While free and open-source virtualization options exist, they are mostly commercial offerings with a high level of vendor lock-in that make operation and changing expensive, difficult, or (sometimes) impossible.
Nearly every container open format is open source, and many conform to the open container spec meaning that it’s easier to change the runtime you use or use a mixture.
There are commercial container orchestrators, and dozens of managed services that offer a wide variety of features, but again, thanks to the underlying open container standards, moving between vendors is much easier.
Containers are one piece of the puzzle, and using them will take your business a long way in enjoying many of the benefits outlined above.
An “orchestrator” helps you manage your containers in a wide variety of ways. While there are several options, Kubernetes (originally built by Google) is by far the most popular option, and what Humanitec is built for. In addition to helping you implement the benefits above, Kubernetes brings reliable automation. It helps you maintain the consistency, scalability, and stability mentioned above. After defining what your application needs to work, it ensures it does by keeping containers running, restarting those that crash, creating and allocating system resources for your application, and increasing resources when increased demand needs them.
On top of automation, Kubernetes handles traffic for your application, routing requests to the appropriate part of an application, and ensuring that resources are not overloaded.
Using Kubernetes also means your team can release updates to an application as often as they want to, and test the changes thoroughly before clients see them.
Containers bring a lot of benefits to your business, but migrating your applications can mean a reasonable amount of work, and changes in practice for your teams. Humanitec’s professional services can support you on this journey.
If you have already containerized your services, register for a free trial and deploy your container images to a Kubernetes cluster in 10 minutes.
No credit card required