What Are Containerized Microservices?

Shipping Boat Represents Containerized Microservices
Shipping Boat Represents Containerized Microservices

Most people know that containerized microservices are essential to cloud migration and digital transformation, but do you have a clear picture of what containerized microservices are and why they’re important?

In this guide, we’ll explain containers, microservices, and how they work together in simple terms – so you finally know what everyone is talking about at the office. 

We’ll do this by covering the following topics:

  • How the Limitations of Virtual Machines Led to Containers
  • What Are Containers?
  • What Are Microservices?
  • How Containerized Microservices Work
  • Tools for Containerized Microservices

Feel free to skip to the sections that interest you most, and share this guide with anyone who needs an easy explanation of containerized microservices.

How the Limitations of Virtual Machines Led to Containers

To fully gain an understanding of containerized microservices, we have to begin with what came before containers: virtual machines (VMs). Organizations have used VMs since the 1960s to run multiple operating system instances on the same server. VMs let you isolate applications from each other for greater stability without investing in another physical server for each instance. 

In this respect, VMs can save you money and resources. The problem is, a VM still uses a lot of system resources. This is because it makes a virtual copy of everything – including the operating system and all the hardware it needs to run. That’s fine if you have enough unused server resources to support the VMs you need. But if you’re running VMs in the cloud, you’re probably paying for the exact amount of server resources you need. 

Spinning up additional VMs require you to buy more cloud RAM, clock time, and operating system licenses. These high costs of running many virtual machines in the cloud is a top reason many are switching to “container” technology. It’s a lighter-weight, faster, and more cost-effective alternative.

What Are Containers?

Containers – or containerized environments – let you virtualize multiple application runtime environments on the same operating system instance (kernel). 

As the popular choice for running microservices applications, containers achieve operating system virtualization by “containing” only what’s required by an application for autonomous operation. They include executables, code, libraries, and files – then packaging it as a single unit of execution. From the perspective of the containerized microservice, it has its own file system, RAM, CPU, storage, and access to specified system resources. It doesn’t even know it’s in a container!

Unlike a virtual machine (VM), containers don’t need to contain a separate operating system image. This makes containers lightweight and portable and significantly reduces the overhead required to host them. In this way, containers give you more virtual runtime environments for your buck. They offer dramatically faster start-up time as well as they don’t have to spin up an operating system when they initiate. 

Being able to run multiple containers on a single OS kernel is valuable when constructing a cloud-based, microservices architecture. Compared to virtual machines, you can run three times as many containers on a single server (or on a single virtual machine). This choice saves a tremendous amount of resources and server costs. 

Did you know you can generate a full-featured, documented, and secure REST API in minutes using DreamFactory? Sign up for our free 14 day hosted trial to learn how! Our guided tour will show you how to create an API using an example MySQL database provided to you as part of the trial!

Access Your No-Code APIs Now

A Brief History of Containers

The idea of “containerization” isn’t anything new. The Linux features that make containers possible – cgroups (control groups) and namespaces – were developed and launched by Google in 2007. Originally known as “process containers,” the Linux cgroups feature lets you isolate processes running in the same Linux kernel. It does this by “containerizing” only the components they require for autonomous operation.

After developing its concept, Google began serving up web-based applications. These apps include Gmail and Google Docs, by using its open-source, Linux-based container solution “lmctfy” (Let Me Contain That For You). In fact, each time you open the Gmail web app, Google launches it in a new container.

Operating system-less runtime environments go back even further than 2007 to the launch of FreeBSD Jails in 2000. FreeBSD Jails let you run, test, and develop a new application in an isolated sandbox before going live. Similar to containers, jails share an operating system with other services and they have limited access to system resources. In addition to jails, we should also mention “Zones” container technology from Oracle Solaris, which came out in 2004. 

These days, Linux – and its cgroups and namespaces features – are the preferred OS for launching containers. Companies like Docker and Kubernetes have also developed powerful open-source technology to make containers more user-friendly, reliable, and secure.

The Benefits of Containers

Before moving on to microservices, let’s review the benefits and characteristics of containers:

  • Reduced overhead and less expensive: Without the need for an operating system image, containers use fewer system resources than virtual machines. This translates into more efficient server utilization and no additional OS licensing costs.
  • Increased portability and consistency across different operating systems: Containerized microservices and apps are easy to deploy on the widest variety of platforms and operating systems. Run them on a PC, Mac, laptop, or smartphone, and they will operate consistently.
  • Faster application development and greater agility: By dividing a monolithic application into a network of containerized, independently-running microservices, application development is faster and easier to organize. Small teams can work more granularly on different parts of an application to develop the highest quality code without the risk of coding conflicts. This results in faster deployment, patching, and scaling.
  • Easier adoption of a microservices architecture: Containers have become the de facto choice for adopting a microservices architecture because they’re less expensive and less process heavy compared to other strategies.
  • Smaller than virtual machines: Containers requirer less storage space. In many cases, they are a hundredth or a tenth of the size of a VM
  • Faster startup than virtual machines: Containers start-up in seconds – sometimes milliseconds – because they bypass the need of a VM to lumber through the process of spinning-up the operating system each time it launches. Faster container initiation times offer an improved app user experience. 

What Are Microservices?

A microservices architecture is a strategy for building applications. It divides what would normally be a monolithic application into a suite of independent, loosely-integrated services – called “microservices.” These microservices work together to create a “pluggable” application architecture. The individual services communicate with each other via language and platform agnostic APIs. The APIs are usually exposed as REST endpoints, WebHooks, or lightweight messaging protocols like RabbitMQ.

Compared to traditional, monolithic applications, microservices applications are more agile and flexible. By keeping the connections between the individual microservices “loose” and “pluggable,” developers achieve an application architecture that facilitates development, upgrades, and maintenance.

Enterprises are also using iPaaS tools like DreamFactory to connect cloud-based microservices to their existing on-premises and cloud-based IT infrastructures. This allows enterprises to quickly integrate new services and features into their existing suite of business systems without extensive coding or delays.   

The Benefits of Microservices

The benefits of microservices include:

  • Reduced interdependencies: With reduced interdependency between the functions and services in the app, microservices offer a pluggable architecture. They  let you easily add, upgrade, or remove features and functions within an application or IT infrastructure.
  • Increased stability and system robustness: When each microservice runs autonomously, the failure of one resource is less likely to negatively affect the entire system.
  • Faster time to market: Developers can focus on building a minimum viable product (MVP) while using existing microservices to complete the rest of an application.
  • More organized development process: Application development teams can divide themselves into small groups that focus on building one microservice. This allows them not to worry about their code conflicting with other parts of the application.

Check out our webinar on microservices 

How Containerized Microservices Work

A great way to introduce how containerized microservices work is to describe the other strategies for running microservices (and explain what’s wrong with them):

  • Each microservice runs on its own physical server with its own operating system instance: This approach keeps the microservices isolated from each other, but it’s wasteful. Considering that modern servers have the processing power to handle multiple operating system instances, a separate physical server for each microservice isn’t necessary.
  • Multiple microservices run on one operating system instance on the same server: This is risky because it doesn’t keep the microservices autonomous from each other. There is an increased chance of failures caused by conflicting application components and library versions. A problem with one microservice can lead to failure cascades that interrupt the operation of others.
  • Multiple microservices run on different virtual machines (VM) on the same server: This provides a unique execution environment for each microservice to run autonomously. However, a VM replicates the operating system instance, so you’ll pay to license a separate OS for each VM. Also, running an entirely new OS is an unnecessary burden on system resources.

Running microservices in containers with their necessary executables and libraries means that each microservice operates autonomously with reduced interdependency on the others. Moreover, multiple containers can run on a single OS instance, which eliminates licensing costs and reduces system resource burdens.

The Linux Features that Make Containerized Microservices Possible

The primary Linux features that make containerized microservices possible are namespaces and cgroups features created by Google in 2007. Let’s take a look at these features and how they work in detail:

Namespaces: The Linux namespaces feature allows you to create an isolated environment. It packages all the components required for a microservice or application to run autonomously. You can run multiple namespace “containers” on the same Linux kernel or virtual machine. From the container’s point of view, it does not know that it’s a “machine within a machine.” Microservices cannot access the system components that belong to the larger system (like process trees, filesystem mounts, user IDs, etc.). It also can’t see the other namespaces, containers, and applications operating on the system. By isolating the execution environment for a microservice and its executables and libraries, you contain the microservice.  No need to quarantine the application code within a separate virtual machine. This reduces server workload and frees up processing power.

Cgroups: The Linux cgroups features complete the container “puzzle” by offering a mechanism to limit and control the system resources given to each containerized microservice.  cgroups lets you assign levels of processing power to different containers according to their need.  You can also aggregate sets of tasks into hierarchical groups with clearly-defined behavior. This creates a more strategic workload placement. The result is a runtime environment that acts like a virtual machine without the processing burdens or costs of a virtual machine.   

Tools for Containerized Microservices

The most well-known tools for building and managing containerized microservices are Docker and Kubernetes. They automate the process of using Linux cgroups and namespaces to build and manage containers. Docker focuses on creating containers, while Kubernetes focuses on container orchestration. CO is the automatic process of managing the work of individual containers for applications based on microservices within multiple clusters. 

Let’s compare some of the most popular tools for containerized microservices in detail: 

Docker

Docker was released in 2013 as the first large-scale, open-source containerization solution. Built to make Linux container features (cgroups, namespaces, etc.) more accessible and easier to use, the Docker platform has since become synonymous with containers and containerized microservices.

Soon after Docker’s release, forward-thinking enterprises began using the platform to build containerized runtime environments. This helped to support their cloud-migration, digital transformation, and microservices efforts. Docker-built containers can immediately reduce cloud-compute overhead expenses for an enterprise by replacing VMs with containers.

Docker’s most popular benefits include:

  • 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.

Docker’s premium Enterprise edition offers powerful extensions, choice of tools and languages, and globally consistent Kubernetes environments. The enterprise edition also includes commercial phone support.

Kubernetes

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.

Working together with Docker, Kubernetes wraps containers in “pods.” Then it automates container deployment and load balancing with the following features:

  • Automatic binpacking: Kubernetes packages your microservices or applications into containers and automatically assigns available resources to the containers based on their requirements.
  • Service discovery and load balancing: Kubernetes automatically configures IPs and ports, and manages traffic for your containers.
  • Storage orchestration: Kubernetes allows you to mount whatever kind of storage system you want to use, whether it’s cloud-based or on-premises.
  • Automatic “healing” to manage container crashes: Kubernetes automatically spins up and deploys an identical container on a different node to replace containers that crash or fail.
  • Autoscaling: Kubernetes includes a variety of features that automatically deploy new containers. They can expand the resources of container clusters, and manage the resources assigned to containers within clusters. These automations trigger according to preset thresholds to ensure overall system stability.

Kubernetes is a highly portable solution. They are now supported by the biggest cloud servers. These include Google Cloud Engine (GCE), Amazon Web Services (AWS), and Microsoft Azure Container Service. Private cloud providers – like OpenStack, Microsoft, Amazon, and Google – have also incorporated Kubernetes container services.

Two popular alternatives to Kubernetes include:

  • Docker Swarm: 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.
  • Apache Mesos: 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.”

Final Thoughts on Containerized Microservices

After reading this guide, you should know what containerized microservices are, and why containers are a cost-effective alternative to virtual machines. You should also be familiar with the most popular tools for launching and orchestrating containerized microservices. After launching your containerized microservices,  you can use DreamFactory iPaaS (Integration Platform as a Service) to establish data connections. This allows them to work together as an integrated whole. DreamFactory automatically generates REST APIs for any database, so you can securely establish data connections between your apps and microservices in minutes.

Start your risk free DreamFactory trial now

Related Articles:

ESB vs Microservices: Understanding Key Differences, Designing Web-Scale Workloads with Microservices, MicroservicesDesigning Web-Scale Workloads with Microservices, Microservices Webinar Recap



Get started with DreamFactory commercial edition by starting a free on-premise trial. Or, start a hosted trial now!