Understanding Serverless

A basic understanding of serverless cloud computing is becoming increasingly important as this technology has evolved and matured in recent years and has exploded in popularity. Some people are even saying we live in a “post-container” world. No matter the hype, serverless computing is a useful technology that provides significant benefits to developers and organizations.

Where traditional virtualization provides hardware abstraction, and containers abstract the operating system, serverless computing abstracts the runtime environment. This means that developers no longer have to think about server resources when building and deploying applications, allowing them to focus on creating value rather than spending time on operations.

The diagram below depicts the consumer responsibility (and resulting abstractions) when using the Infrastructure as a Service (IaaS), Container as a Service (CaaS) and Functions as a Service (FaaS) cloud services models.

In its essence, serverless computing provides “functions” which provide data processing for your code using many different programming languages. You simply upload your code and it sits dormant until it needs to be executed. You pay for only what you use, and the functions can scale elastically as required.

There is still a server processing the functions of course, however it is fully managed by the cloud service provider and is not visible to the consumer. Please note there are additional “serverless” computing offerings available other than functions, but this article focusses mainly on functions.

 

Benefits

The key benefits of serverless computing include:

  • There are no servers to manage
  • Fast instantiation of code
  • Continuous scaling (elasticity)
  • Pay only for what you use
  • Completely dynamic (everything is automated)
  • Services based (or functions based; ideal for microservices architectures)
  • Dynamic access to cloud resources

Use cases for serverless computing include performing real-time data processing for many types of applications, building scalable back-end services that are able to provide self-scaling, and to bind and choreograph systems into integration services, applications, and processes.

It’s key to understand that serverless computing is not a good fit for all use cases however. The best use cases usually include applications that are net new “cloud-native” architectures, which require elasticity, and that are based on services-oriented architectures such as microservices architectures.

Serverless computing is not so good for legacy applications that do not require elasticity, and that are based on monolithic components (not services-oriented). In some cases it may also be cost prohibitive, or there may be specific security or compliance issues to be considered.

When serverless functions are offered as a service by a public cloud provider they are often known as Functions as a Service (FaaS). AWS Lambd is one of the most well-known offerings.

 

AWS Lambda

AWS Lambda was one of the first serverless computing offerings in the public cloud space and has the largest user base today. Lambda natively supports Java, Go, PowerShell, Node.js, C#, Python, and Ruby code, and provides a Runtime API which allows you to use any additional programming languages to author your functions.

Each AWS Lambda function runs in its own isolated environment, with its own resources and file system view. Code is stored in Amazon S3 and is encrypted at rest. Though there is a default safety throttle for concurrently executing functions, you can in theory scale to any level.

Lambda executes in response to triggers from an event source. An event source is an AWS service or developer-created application that produces events that trigger an AWS Lambda function to run. For example, S3 can trigger Lambda to execute a function when an object is uploaded to an S3 bucket.

The image below depicts an object being uploaded to Amazon S3, which triggers a Lambda function to resize the images into various sizes for different devices, and then store the results:

As mentioned previously, serverless functions are not the only form of serverless computing, AWS (and other providers) offer other managed services that deliver computing services without the need for the consumer to manage the underlying operating system. These include (amongst others):

  • AWS Fargate (containers)
  • Amazon Simple Storage Service (S3)
  • Amazon DynamoDB (NoSQL DB)
  • Amazon API Gateway