Pricing Login
Pricing
Back to blog results

August 22, 2019 By Kalyan Ramanathan

Serverless vs. Containers: What’s the Same, What’s Different?

Containers and serverless computing are two of today’s hottest technologies for application deployment. When used the right way, they both help DevOps teams to deploy applications faster and more cost-effectively.

Although the features of containers and serverless architectures overlap in some respects, they are not interchangeable technologies. Containers work better for some use cases, while in others, serverless is what you need.

This article discusses the similarities and differences between containers and serverless computing services and explains why a DevOps team might choose one technology or the other, depending on that team’s needs.

What are Containers?

Put simply, containers are a lightweight virtualization architecture. They allow you to deploy individual applications (or, in some cases, complete operating systems) inside portable, isolated environments.

Because containers share system resources with the host server rather than emulating a virtual operating system, they are more efficient than virtual machines.

In addition, by isolating an application from the external host environment, containers enable frictionless application deployment. As long as your host server supports whichever container runtime you use, you can deploy containerized applications on it, without having to worry about tweaking the application configuration or fighting with environment variables to get things working. For the same reason, you can move containerized applications easily between hosts.

What is Serverless?

Serverless computing is an execution architecture in which application code is run on demand. From the user’s perspective, the only work necessary to run the code is to upload it and trigger when it should execute. That’s why it’s called serverless—There is no server to maintain.

The major advantage of serverless is that it allows users to execute code whenever they need, without having to maintain a host environment on an ongoing basis. This can help to save money, particularly in cases where you need to execute resource-intensive code.

How Containers and Serverless are Similar

Containers and serverless are not identical technologies. However, they do provide certain overlapping functionality:

  • Both allow you to deploy application code.
  • Both are more efficient than virtual machines.
  • Both abstract applications away from the host environment.
  • Both require orchestration tools to use effectively at scale.

Differences between Serverless and Containers

Their similarities end there. In all other ways, serverless and containers are distinct technologies.

Following are key differences between containers and serverless:

  • Supported host environments: Containers can run on any modern Linux server, as well as certain versions of Windows. In contrast, serverless runs on specific host platforms, most of which are based in the public cloud (like AWS Lambda or Azure Functions).
  • Self-servicing ability. For the reasons just noted, in most cases, serverless functions require you to use a public cloud. (There are on-premises serverless frameworks, like Fn, but these are not yet widely used.) With containers, you can set up your own on-premises host environment, or use a public cloud service like ECS.
  • Cost. Because serverless environments are hosted in the cloud, you have to pay to use them. In contrast, you can set up a container environment yourself using open source code for free (although you’ll still have management costs, of course).
  • Supported languages. You can containerize an application written in any type of language as long as the host server supports the language. Serverless frameworks are different; they support a limited number of languages. The details of supported serverless language vary from serverless platform to platform.
  • Statefulness. Most serverless platforms are designed to support stateless workloads. (Some serverless providers offer limited support for stateful services; cf. Durable Functions on Azure.) Although you can connect to external storage services (like S3 on AWS) from within serverless platforms, the functions themselves cannot be stateful. Containers present their own persistent storage challenges, but creating stateful containerized apps is certainly possible.
  • Availability. Serverless functions are designed to run for a short period—usually, a few hundred seconds—before they shut down. Containers can run for as long as you need.

Serverless vs. Container Use Cases

Because of the differences described above, containers and serverless cater to different use cases.

Containers are ideal for situations where you need to:

  • Maintain environment parity as application code moves down the delivery chain.
  • Move applications quickly between different host servers.
  • Retain the ability to move workloads between on-premises and the cloud.
  • Make services available on an ongoing basis.

Meanwhile, serverless is great when you want to:

  • Execute resource-intensive code quickly on a one-off basis. For example, if you need to run code to resize images whenever users upload them, serverless can be a great way to do that.
  • Run finite amounts of application code in the cloud without having to set up a virtual server or pay for ongoing cloud resources.

Conclusion

Rather than thinking in terms of containers vs. serverless, it’s better to think of containers and serverless as technologies that complement each other. Most organizations are likely to use containers and serverless, not one or the other. In fact, you might even use both technologies to help deliver the same application.

Containers

Serverless

Isolate workloads?

Yes

Yes

Stateful functions/apps?

Yes

In most cases, no

Host environment

Cloud or on-premises

Mostly cloud

Cost

Free if you set up yourself

Requires paying fees to cloud provider

Supported languages

Virtually any

Limited

Support persistent services

Yes

No

Complete visibility for DevSecOps

Reduce downtime and move from reactive to proactive monitoring.

Sumo Logic cloud-native SaaS analytics

Build, run, and secure modern applications and cloud infrastructures.

Start free trial
Kalyan Ramanathan

Kalyan Ramanathan

Kalyan has more than 20 years of experience in software and marketing and brings a a deep understanding of the IT operations and management market.

Prior to Sumo Logic, Kalyan was the VP of Product Marketing at AppDynamics. He has also served as CMO at Crittercism, VP of Marketing at Electric Cloud and as Senior Director of Product Marketing at Opsware/HP.

Kalyan began his career at Intel and has an MBA from the Stanford Graduate School of Business.

More posts by Kalyan Ramanathan.

People who read this also enjoyed