AWS Lambda v Amazon ECS — two paths to one goal, which is best?

Launched in parallel two and a half years ago by Amazon Web Services (AWS), AWS Lambda and Amazon EC2 Container Service (ECS) are two distinct services that each offer a new, leaner way of accessing compute resources. Amazon ECS lets developers tap into container technology on a pay-as-you-go basis. AWS Lambda offers what is often known as ‘serverless’ computing, or function-as-a-service — the ability to access specific functions, again on pay-as-you-go terms.

On the surface, they both serve the same goal — provide a compute environment for applications, services and microservices that allows developers to focus on the application, not on the infrastructure.

But why are there two distinct services? What’s the difference between them? And, most importantly, when would I use one versus the other?

Great questions. Let’s take a look at each service … But first, for clarity, a quick explanation. To avoid confusion of the term ‘service’ in this article, I will refer to applications, whether they are monolithic or elementally broken into services, as application services or simply applications. I will refer to the AWS services such as AWS Lambda and Amazon ECS generically simply as cloud services or AWS services. OK, now that’s clear, let’s move on.

What is AWS Lambda?

AWS Lambda allows custom code to execute in response to triggers caused by activity from other AWS resources, services, and web apps. AWS Lambda provides this capability by allowing specially constructed code segments (called Lambda functions) to execute in an environment where the infrastructure becomes totally invisible and irrelevant.

Scaling and server management are handled transparently by AWS. The user isn’t even aware of, and has no visibility into, how the servers are organized to execute the functions — this is all hidden from view by AWS.

The downside of this approach is that the code segments (functions) that run in AWS Lambda are quite limited in what they can do — they must be relatively small and simple. These requirements are enforced not only by the execution environment provided, but by the pricing model put in place for the cloud service.

What is Amazon ECS?

Amazon ECS allows running Docker containers in a standardized, AWS-optimized environment. The containers can contain any code or application module written in any language.

Rather than being handled by AWS, scaling and server management has to be set up by the user. The containers themselves run on standard Amazon EC2 instances that are configured with special Amazon ECS software. These underlying Amazon EC2 instances within an individual cluster of servers can be of any size or quantity, depending on your application’s scaling needs. Via the Amazon ECS software, configuration and management of the underlying cluster is used to determine where, how many, and how each container is to execute on the given cluster. The Amazon EC2 instances in the cluster must be sized and scaled by the user to handle the quantity and execution demands of the containers.

AWS Lambda v Amazon ECS

AWS Lambda and Amazon ECS are similar in many regards. The code that the two AWS services execute does not have to have any visibility into the underlying infrastructure. The infrastructure decisions you must make in operating the service can be made independently from application coding decisions. If constructed properly, the code on either AWS service can provide significantly valuable scaling capabilities.

However, the two services differ in some very substantial ways. AWS Lambda does not provide any visibility into the server infrastructure environment used to run the application code, while Amazon ECS actively exposes the servers used in the cluster as standard Amazon EC2 instances and allows (or more correctly requires) the user to size and scale their fleet themselves.

AWS Lambda functions must be written in one of a handful of supported languages and are restricted in the type of actions they can perform. Amazon ECS, on the other hand, can run any container using any code that is capable of running in a container (which is almost any application that runs on a typical Linux operating system).

AWS Lambda is optimized for simple and quick functions to execute. Larger and more complex functions create execution complexity (and significant execution cost) to the user. Amazon ECS, on the other hand, can be used with any reasonable size and complexity container.

With AWS Lambda, all scaling and sizing decisions are made automatically and continuously by AWS. This allows a complete hands-off solution where the user can ignore most scaling issues. Amazon ECS, on the other hand, requires the user to knowingly understand the required server fleet sizing and make active decisions to resize the fleet as necessary as scaling needs change.

Which AWS service should I use?

Either one of these services can be used to run applications or application services. So, which AWS service should you use for a particular purpose? The answer depends on the needs of the application. If you want to run very small actions that are relatively simple in complexity, AWS Lambda provides a compelling hands-off solution to a highly scalable application. If your application or applications services have any complexity to them at all, Lambda may be too restrictive and too expensive to operate, and Amazon ECS may provide better options for you.

Of course, it is perfectly reasonable for different application services within a single application to separately use either of these two AWS services. As such, some of your application may run in AWS Lambda, and other parts of your application run in Amazon ECS.

I personally would like to see another option. I believe AWS should support a hybrid service. That is, a service with the infrastructure opacity and ease of management that Lambda provides, but which allows the code that is executed to be written and executed within a container environment. This will allow the best of each offering: versatility of container-based applications with the simplified infrastructure management available from AWS Lambda. This would be the best of both worlds, and I hope AWS is considering such a service.

Originally published at diginomica.com on June 29, 2017.

The London Sunday Times: Raconteur: Serverless computing

Serverless computing is one of the hottest trends in tech, however it’s also one of the most misunderstood. From the article:

Lee Atchison, senior director at analytics platform New Relic, warns: “Each service provides a different and unique method for offering serverless computing. This means that an IT professional who wants to take advantage of serverless computing will find they are locked into a single cloud service provider to a greater degree than if they use more standardised traditional server-based computing.”

Read More

Building Right-Sized Application Services: The Goldilocks Calculation

In the world of applications, services are standalone components that, when connected and working together, create an application that performs some business purpose. But services come in a wide variety of sizes, from tiny, super-specialized microservices up to services big and complete enough to form their own monolithic applications. Just like Goldilocks looking for the perfect fit, it’s not always easy to determine the right size for the services you need to build your organization’s apps and meet your business goals.

Read More

Goldilocks, serverless and DevOps: Five predictions for IT in 2017

Technological innovation drives every business, industry and sector - mostly positively, but not always. 2016 was no exception – from the first long-haul driverless cargo delivery to automated retail locations to the stiffening competition among ‘smart assistants’ we’re seeing big technological leaps at a breakneck pace.

At the same time, many of the enterprise trends of the last few years are continuing, such as traditional businesses leading big digital transformation and the move to public clouds, with the continued market dominance of Amazon’s $13B AWS business.

As 2016 draws to a close, it’s time to once again consider how the IT industry will grow, adapt, evolve and transform in the coming year, and to consider what lies in store for 2017. Here, I set out my top five predictions for what we can expect to see over the next 12 months and beyond.

Read More

Visibility into the Migration From Static to Dynamic Infrastructure [Video]

When I look back at my career over the last 30 years, it’s amazing to see how much the world has changed when it comes to building, running, and managing software. At my first job, for example, our company was trying to reduce its development cycle down to less than a year. Nowadays with cloud architectures we’re seeing development cycles of just weeks, days, or even hours. But that’s not to say that all cloud environments are dynamic and rapidly changing.

Read More

Why I Wrote the Book on ‘Architecting for Scale’

As applications grow, two things begin to happen: they become significantly more complicated (and hence brittle), and they handle significantly larger traffic volume (which more novel and complex mechanisms manage). This can lead to a death spiral for an application, with users experiencing brownouts, blackouts, and other quality-of-service and availability problems. “But your customers don’t care. They just want to use your application to do the job they expect it to do. If your application is down, slow, or inconsistent, customers will simply abandon it and seek out competitors that can handle their business. That’s how my new book, Architecting for Scale: High Availability for Your Growing Applications, begins.

Read More

Distributing the Cloud - AWS Architecture - Part 3

We all know the value of distributing an application across multiple data centers. The same philosophy applies to the cloud. As we put our applications into the cloud we need to watch where in the cloud they are located. How geographically and network topologically distributed our applications are is just as important as with normal data centers. While Amazon AWS won’t tell you specifically where your application is running, they do give you enough information to make diversification decisions. Interpreting and understanding this information, and using it to your advantage, requires an understanding of how AWS is architected. In part 1 of this article, we talked about the AWS Architecture of regions and availability zones. In part 2, we went into more detail about how availability zones are structured, and how we can utilize this information. In this final part, we discuss the availability zone to data center mapping, why it is important, and how to use all this information to make sure you have the highest diversification as possible for your application.

Read More

Distributing the Cloud - AWS Architecture - Part 2

We all know the value of distributing an application across multiple data centers. The same philosophy applies to the cloud. As we put our applications into the cloud we need to watch where in the cloud they are located. How geographically and network topologically distributed our applications are is just as important as with normal data centers. While Amazon AWS won’t tell you specifically where your application is running, they do give you enough information to make diversification decisions. Interpreting and understanding this information, and using it to your advantage, requires an understanding of how AWS is architected. In part 1 of this article, we talked about the AWS Architecture of regions and availability zones. In part 2, we will go into more detail about how availability zones are structured, and how we can utilize this information.

Read More

Distributing the Cloud - AWS Architecture - Part 1

We all know the value of distributing an application across multiple data centers. The same philosophy applies to the cloud. As we put our applications into the cloud we need to watch where in the cloud they are located. How geographically and network topologically distributed our applications are is just as important as with normal data centers. However, the cloud makes knowing where your application is located harder. The cloud also makes it harder to proactively make your application more distributed. Some cloud providers don’t even expose enough information to let you know where, geographically, your application is running. Luckily, larger providers like AWS are better. No, AWS won't tell you specifically where, geographically, your application is running, since they do not disclose their actual data center locations (I worked at AWS, and I have no idea, specifically, where the data centers are located). While they won’t tell you specifically where your application is running, they do give you enough information to make diversification decisions. Interpreting and understanding this information, and using it to your advantage, requires an understanding of how AWS is architected.

Read More

Scaling with Availability

One of the most important topics in architecting for scalable systems is availability. While there are some companies and some services where a certain amount of downtime is reasonable and expected, most businesses cannot have any downtime at all without it impacting their customer’s satisfaction, and ultimately their company’s bottom line. How do you keep your customers happily using your service and keep your company’s revenue coming in? You keep your service operational as much as possible. There is a direct and meaningful correlation between system availability, and customer satisfaction.

Read More

Why Use Microservices?

Traditionally, software companies created large, monolithic applications. The single monolith encompasses all business activities for a single application. As the company grew, so did the monolith. In this model, implementing an improved piece of business functionality requires developers to make changes within the single application, often with many other developers attempting to make changes to the same single application. Developers can easily step on each other’s toes and make conflicting changes that result in problems and outages. Development organizations get stuck in the muck, and applications slow down and become unreliable. The companies, as a result, end up losing customers and money. The muck is not inevitable, you can build and rearchitect your application to scale with your company, not against it.

Read More

Welcome!

Scaling web applications isn’t easy. As web applications grow, two things begin to happen. First, they become significantly more complicated and hence brittle. Second, they handle significantly larger traffic volume requiring more novel and complicated mechanisms to handle this traffic. This can lead to a death spiral for an application that can lead to brownouts, blackouts, and other quality of service and availability problems. My purpose for this blog is to provide techniques, guidance, and best practices for how to build web applications that scale to significant traffic volumes.

Read More