Software Engineering Trends

Dineshkumar Yadav
Aug 2 · 4 min read

A brief guide on serverless applications with AWS Lambda

Prelude

Function as a Service or Serverless Architecture is a software design paradigm where the responsibility of provisioning and managing infrastructure is eliminated for developers with on-demand compute services completely managed by Cloud Providers in real-time. The application is cluster of lightweight individual functions that can be invoked and scaled individually.

Why do we need Serverless Microservices?

Before jumping more into the Serverless Architecture, we must understand why there was a shift from traditional server based applications to cloud computing and eventually towards serverless applications.

Building and maintaining the system infrastructure has been the biggest pain for any enterprise. Not only it increases the workforce deployment but also decreases the bias for action needed within the organizations. With Increase in market competition, there was a need to cut-off the unnecessary burden of infrastructure maintenance and focus on actual business to thrive in this dynamic market.

What is a Serverless or Function as a Service

‘Serverless’ as the name suggests is an application with no traditional server infrastructure. A Serverless application is a server side logic written and it runs in a stateless compute container that is triggered via an event driven ecosystem. Each function in a serverless premise, is written as an individual and autonomous function. Individual functions can be scaled and invoked separately. It is a cloud computing execution model where third party cloud provided dynamically scale the server infrastructure to meet the load requirement of the application.

Let’s elaborate it more through an example -

Illustration — Function as a Service in a common software enterprise product

In the above diagram, a sample enterprise product is managing 3 different services -

  1. Authentication — Authenticates the User
  2. Product Listing — Lists the available products
  3. Product Selection — Processes the selected product

In a traditional server based architecture (on premise as well as cloud), these services will be hosted on separate instances and the developer has to take care of provisioning, scaling and maintaining the infrastructure. But in serverless architecture, these services are implemented as short lived functions for e.g. AWS Lambda Function, which run on containers and are automatically scaled and maintained by the the Cloud provider; AWS. Once a function returns after process completion, the occupied resources by the function are automatically released. Therefore, a software developer would only need to focus efforts on the actual development tasks rather than infrastructure provisioning, maintenance and other related tasks.

Amazon Web Services pioneered the idea of stateless and serverless computing with the launch of AWS Lambda functions in 2014. Today, it is the most popular and preferred choice among developers for function as a service. AWS Lambda further offers a ton of flexibility by allowing a developer to customize the compute environment, such as memory, execution duration and elastic scaling as per application load.

What are some trade-offs with ‘Function as a service’?

While the idea of stateless and serverless compute ushers a new paradigm shift in the tech-industry, there are some pitfalls that need to be understood thoroughly during the software design process.

Here are a few known pain-points —

  1. Execution duration: As of today, Lambda Functions are only allowed to run within limited duration (15 mins) and it gets timed out upon exceeding the threshold. Hence, Function as a service is not suitable for long lived tasks. Generally, short lived functions are combined with long lived workflows, such as AWS step functions, to handle the long running processes.
  2. State: Function as s service is stateless. i.e. the state of the objects and variables are restricted to single container and single invocation. Thus, state from one invocation of a function will not be available to another invocation of the same function.
  3. Cold start: It takes some time for a FaaS container to initialize an instance of a function before each event. This startup latency can vary significantly, even for one specific function, depending on a large number of factors, and may range anywhere from a few milliseconds to several seconds.

Despite of the above mentioned pitfalls, serverless applications have caught the momentum in today’s software race. Most enterprises have overcome the limitations with supplementary services like Step Functions, periodic initiation calls to combat cold start, etc. The Lambda service from AWS has also matured over the past 5 years and we continue to expect further enhancements towards an ideal serverless service.

Concluding Thoughts

AWS Lambda has truly ushered a new paradigm shift in software development and architecture design of enterprise products. In the coming days, we expect to see serverless as the new norm in software development.

Dineshkumar Yadav

Written by

Software Developer, Learner and Sharer. @Amazon Web Services

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade