Moving to Serverless with Lambda

Written by Francisco Gimeno

What is AWS Lambda?

AWS Lambda is an implementation of Function as a Service, which allows you to run your code without provisioning or managing servers. The exciting part is that you only pay for the compute time you consume, getting full elasticity.

Moving to Serverless with Lambda

Image courtesy: AWS

Why do you get savings?

With an EC2 instance, you pay for the compute engine all the time it’s switched on, even if you’re not using it. With Lambda, you only pay for the exact duration you’re using it that can be as short as 100ms for each request. This is ideal for unpredictable traffic. (UPDATE: AWS launched per ms billing for Lambda on Dec 2020)

Nevertheless, the price per unit of vCPU is higher in AWS Lambda, which means that there will be a breakeven point when other solutions are cheaper. However, AWS brings other benefits that should also be considered.

What other benefits do you get?

There are some additional benefits of moving to Lambda:

  • AWS Lambda scales automatically, and is able to support all sizes of workloads.
  • Lambda can be connected easily to other services such as AWS API Gateway to map external URLs to your applications.
  • The code upgrade process is usually done with zero downtime. 
  • Security by default, as the attack vector is reduced considerably. There is no need to protect any server, just configure who can access the Lambda, and integrate it with AWS Cognito for authentication.
  • Also, for Security, granting permissions to Lambda is more secure with Roles than deploying the service account credentials into servers.
  • Finally, with minimal effort, you can have your Infrastructure as Code using tools such as Serverless, SAM, or CDK.

How hard is it to migrate to Lambda? 

If the existing code is in any of the supported languages, then it’s just a matter of refactoring the code to split functionalities into different modules or microservices. That might sound easy, but it depends on the complexity of the application, the quality of the code, and the third-party libraries.

Also, some pieces of common code will need some fundamental changes (such as an authentication module or the storage backend to remove the dependency on local storage and use shared storage instead, such as S3 or NFS).

Those stateless or web applications, with or without well-defined authentication mechanisms are the best candidates for the initial adoption of this technology.

Determine the most suitable workload for you with Cloudwiry’s serverless analysis feature.

Further reading: Moving to Serverless with Fargate

For more strategies on how to optimize your cloud, schedule a call with our cloud experts or drop us an email at