Blog
-
Expert reacts

Serverless Computing with AWS Lambda

Reading time: ca.
3
minutes

If you're a software developer, you've likely heard some buzz surrounding serverless computing and its potential to revolutionise the way we build and deploy applications. At the forefront of this trend is AWS Lambda – Amazon's powerful, pay-as-you-go serverless computing platform that allows developers to run code without provisioning or managing servers.

As software development consultants, we’ve seen first-hand how Lambda can improve efficiency, scalability, and save on costs for businesses. We decided to put together this guide based on our internal bootcamp, to help developers get started and take advantage of its many benefits. Let's dive in and explore the exciting world of Lambda together with Iderisse Dom, who leads our bootcamps.

Why We Prefer AWS Lambda

If you’re a developer, chances are that we don’t need to convince you about the benefits of serverless computing anymore. Being able to build and run applications without having to bother with provisioning and managing servers is a clear benefit. Other benefits include pay-per-use models and automatic scaling. If you’re working with event-driven architectures, serverless is pretty much the go-to option.

The next choice is a less obvious one. The Serverless Framework, an open-source platform that abstracts away the underlying infrastructure, works just as well with competitors like Google Cloud Functions and Azure Functions. So why choose AWS Lambda?

It boils down to personal preferences and your clients’ existing infrastructure, but we prefer Lambda for its maturity, excellent performance, wide range of use cases and ease of use. It has existed longer than its competitors, so it has the most features, best documentation, and tooling and performance out of the box, including advanced scaling capabilities.

AWS Lambda supports several programming languages, including Java, JavaScript, C#, Golang and Python, so you probably won’t have to learn a new language. There are also several integrations with other Amazon services that will help you streamline your workflow. With Lambda, you can set up your code to respond to triggers such as changes to data in an S3 bucket, a new item in a DynamoDB table, or an HTTP request using API Gateway.

Building a Scalable Architecture with AWS Lambda

While AWS Lambda's pay-per-use model provides a significant cost advantage, it also means that you need to pay close attention to scalability. To build a scalable architecture, your functionals will need to be designed to handle varying levels of traffic, with proper triggers to activate them.

At Optis, we organise internal bootcamps to help our developers get up to speed with AWS Lambda and serverless computing in general. Here are some practical tips we’ve learned to keep in mind when working with AWS Lambda:

  • Be pragmatic about where you use serverless computing in terms of architecture. While it is cost-effective and scalable for event-driven applications, traditional methods may be better for tasks with very long-running timeframes.
  • AWS Lambda works great for new software, but you can't easily take an existing application and make it a Lambda.
  • Define proper triggers for your functions to activate them in response to specific events.
  • Use queues to decouple functions and make your system more resilient. Check out our blog post on Amazon Simple Queue Service for more information.
  • Don't try to put everything in one Lambda, but use proper domain-driven design  knowledge to split the application up in the right way.
  • Use an S3 bucket to store files and set the permissions for the bucket.
  • Be aware of the return type in your function, as it can lead to strange errors.

We used to point out the importance of accounting for lifecycle timeouts and cold starts as well, since this can lead to longer response time. With the recent release of the SnapStart feature, however, cold starts are unnoticeable in normal use when designed correctly.

I'm thrilled to share some best practices with Optis developers in our serverless computing bootcamp and help them harness the full potential of AWS Lambda!

Advanced AWS Lambda Capabilities

Now that we have covered the basics of AWS Lambda, let's explore some advanced capabilities that can help you to build more complex serverless architectures.

One powerful feature of AWS Lambda is the ability to link functions together using AWS Step Functions. This allows you to execute Lambda functions sequentially, passing data between them as needed. By using Step Functions, you can create complex workflows that can help you to avoid time-outs and the accompanying unclear error messages.

For example, let's say you have a function that needs to perform several tasks in order. By using Step Functions, you can break these tasks down into separate functions and link them together, ensuring that each one completes before the next one starts. If one of the tasks fails, the entire workflow will fail, allowing you to easily identify and fix the problem when coupled with error handling logic like retries and dead queues.

Another important capability of AWS Lambda is logging. AWS provides a logging service called CloudWatch that allows you to monitor and troubleshoot your Lambda functions. By logging important events and errors, you can gain insight into how your functions are performing and quickly identify any issues that may arise.

In addition, debugging can be more challenging with serverless architectures, but Amazon has developed an AWS Toolkit that allows you to debug serverless code locally using debugging tools like breakpoints. No more complicated interfaces: you’ll be able to troubleshoot your code right from your IDE.

Lastly, it's important to consider security when building serverless applications. If you want to stay within the AWS ecosystem, you can use Cognito, which provides user authentication, authorisation, and user management for web and mobile apps. By integrating Cognito with your Lambda functions, you can encrypt and secure user data and ensure that only authorised users can access your application.

Conclusion

Serverless computing and AWS Lambda offer significant benefits, including automatic scaling and pay-per-use pricing. By following some best practices and using AWS Step Functions to link functions together, you can build a scalable and efficient architecture with relative ease. While there are some potential drawbacks for excisting applications and tasks with long-running timeframes, the benefits make it an attractive option for many use cases like event-driven processes, webhooks, scheduled tasks, and data transformations.  

Want to leverage the power of AWS Lambda and serverless computing in exciting development challenges? We’re always looking for new talent to join us, so be sure to check out the fullstack developer vacancy and others on our careers page!

Iderisse Dom

April 17, 2023

Read the highlights of our blog

"Each project pushes our skills farther and expands our expertise"

Let's talk!

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
We value your privacy! We use cookies to enhance your browsing experience and analyse our traffic.
By clicking "Accept All", you consent to our use of cookies.