How AWS Lambda powers microservices applications

If it seems to you like the cloud is set out to virtualize every layer of server room hardware, you’re not wrong. And now, with AWS Lambda, it looks like the servers themselves are in danger of being replaced. A lot of people have heard the term “serverless” by now, and it goes without saying that the term can be slightly misleading. What AWS Lambda effectively does is take away the pain associated with running and maintaining servers to a point where developers can concentrate on their code in a “serverless” environment.

As of now, the entire process of software development still revolves around the concept of a server. Provisioning, maintaining, and scaling application infrastructure is still something that developers need to spend time and effort on. This is true whether you manage hardware servers in your own private datacenter, or cloud instances in AWS. When AWS Lambda was launched in 2014, it didn’t make the job of maintaining infrastructure disappear, but rather it took complete ownership so that developers could break free from the time-consuming server maintenance efforts and focus solely on developing applications.

Event-triggered functions

A lot of people may feel that this is no different from Platform as a Service (PaaS) offerings, and definitely no reason to call this “serverless.” Well, here’s where we actually get into the meat of the matter, which is AWS Lambda is “event driven.” What this means is that when you load your application into AWS Lambda, it essentially doesn’t exist, or is “sleeping” until an event trigger is used to call a function. When the event is triggered, your application pops into action, does what it needs to do, and disappears again. Some people may still be wondering what the point of this whole operation is. The point is you don’t pay for anything while your application is sleeping, you only pay for resources used when events are triggered. That’s where we start calling it “severless” because, in essence, your server doesn’t exist until it is needed.

So now we have defined AWS Lambda as a service that not only runs your code in response to events but also manages the compute resources for you. When compared to an Infrastructure as a Service (IaaS) offering like AWS EC2, where you have to pay for server uptime regardless of utilization, AWS Lambda only requires you to pay when your code is actually running — and the best part is that charges are rounded off to the nearest 100 milliseconds.

This is a huge leap from the hourly round-off that EC2 instances offer. And what’s more, Lambda comes with a free tier that includes a million free requests and 400,000GB seconds of compute time per month. There are reports of users bills dropping by 90 percent on AWS Lambda, and at a serverless conference there were two presentations that indicated applications with considerable use were actually operating within the free tier. One question obviously arises: Why is AWS shooting itself in the foot, so to speak, by undercutting their own offerings by 90 percent? Obviously, AWS believes they’re onto something here, and with the way the other tech giants have rushed to market with their own serverless offerings, they are probably right.

Microservices: The breakdown

When you load an application on a VM or a container, your operations team is still responsible for managing the execution environment that runs the code. Though containers are highly scriptable, they still need to be maintained throughout their lifecycle. At the end of the day, all backend products are a collection of functions that yield certain responses. What AWS Lambda does is it lets you break down your system into smaller pieces called microservices that can be invoked either by an API call or an event triggered within the AWS ecosystem.

Monolithic vs Microservices application approach
Microsoft

This breakdown of your functions into microservices not only makes them a lot more manageable, but also a lot more economical to run. Each function can be invoked separately when required and then disappear again leaving a much smaller resource footprint as well.

According to a recent survey, the leading use of serverless architecture is in the use of web services, or in other words, “serverless websites.” This isn’t really surprising since we know that event-triggered programs stand to gain the most by going serverless, and web services are mostly event triggered anyway. In this case the web frontend sends requests to Lambda functions via an API Gateway, and Lambda in turn handles the application logic.

Some popular use cases

If you look at applications in the wider context of the word to include mobile apps, web apps, chatbots, and the IOT, this makes up for the majority of AWS Lambda use cases. While a lot of these early adopters of Lambda are startups, the enterprise in general seems to be taking an interest with regards to specific workflow processes and to trigger and manage automated actions. However, one common frontrunner for serverless architecture among both startups and the enterprise is in the field of image recognition. AWS Rekognition is one such tool from Amazon with which you can use AWS Lambda functions to process newly uploaded photos at any desired scale.

Similarly, IBM’s serverless tool OpenWhisk demonstrated a use case with a drone that takes aerial photographs and then uses cognitive APIs to analyze data in these images. At a recent conference, Tim Wagner, general manager of AWS Serverless Compute, mentioned that image processing is one of the most interesting use case areas for serverless. AWS Lambda is extremely useful for completing tasks that require high compute power like image processing. The automatic demand-based scaling make it even more useful, especially for startups that don’t want to spend a lot of money on expensive equipment.

VidRoll, a popular video technology and monetization platform for content publishers, was having difficulty managing clusters of EC2 instances. To overcome these difficulties, VidRoll now uses AWS Lambda to power the business logic for real time ad bidding and to transcode video ads in real time. After shifting to AWS Lambda, VidRoll now claims to be able to do with two or three engineers what originally took at least eight or 10 engineers before. One of the big advantages of Lambda is that performance is enhanced due to code reusability.

Localytics is a web and mobile app analytics and engagement company that has among its clients ESPN, The New York Times, eBay, Fox, and Salesforce. With their software being used in over 30,000 apps and 3 billion devices worldwide, the Boston-based company was having a problem supporting pipelines with billions of datapoints being loaded every day. They now use AWS services to send 100 billion datapoints every month, and for each new feature, AWS Lambda creates a new microservice to access the Amazon Kinesis data stream.

AWS Lambda has been set up change the way we approach software development. If your application can easily be split into independent components, there really isn’t a downside to using AWS Lambda, and the free tier and low pay-per-use pricing model make it all the more enticing. However it’s important to always remember that going serverless needs to be based on how compatible your code is with being split up into microservices — and not just because it’s the latest trend.

Leave a Comment

Your email address will not be published.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top