Lambda: Beyond APIsCloud-based API consumption has made building an application based on a cloud service easier than ever. But with great power comes great complexity. The code can quickly introduce unnecessary duplication, both in application logic as well as in server resource consumption. When you trigger an event (more on this below) sending events true to your API, there are not necessarily any constraints for these kinds of event interactions. And you pay for the server resources that are behind your APIs whether you’re using them or not. Lambda Serverless functions solve this problem in two ways, indirectly and directly.
Less Cost, More Optimization.The direct impact of serverless functions is how it helps by optimizing server resources. Once you’ve gotten a well-specified Lambda function, it is easier to see how to get it to use fewer resources. When a well-specified event takes a hundred milliseconds, you only paid for 100 milliseconds — and not for a hosted instance that’s always on. To be clear, the great advantage of pay-as-you-go with Lambdas depends entirely on where you are going (aka YMMV). Because Lambda helps you narrow on which events consume which resources, you don’t ”leave the motor running” without knowing what work the motor is doing. We’ve seen more than one EC2 implementation where the load for various APIs calls outstripped what was originally built into the server stack, leading to surprises when the AWS invoice shows up. Lambda makes that work much more clear and much more transparent. What’s more, developers don’t need to tangle with questions of containers, OS versions, network operations, load balancing, and other questions of managing infrastructure services. “Zero Admin” doesn’t mean that you never need servers. It means application devs are not spending a ton of time as part-time admins. Lambda serverless takes care of all of the scaling and resource management. Developers take care of the functions, leaving infrastructure administration to the infrastructure team.
Lambda Use Cases we have helped withNot all event triggers are well-suited to Lambda, of course. However, the more the events are irregular or unpredictable, the more money and headache you can save by working with Lambda. Generally speaking, Lambdas can be applied to more effectively structure interactions among server components, or to better manage steps in the data pipeline. Here are a couple of examples we have implemented at clients recently:
- Security and Operations: When a user sends a request to the API gateway, a Lambda acts as an authorizer, and either validates the access token before proxying it to the internal service; or rejecting it, calling another Lambda function to triggeran alarm email and log it S3. Read more
- Data processing: Kinesis Firehose receives a wad of data from IoT sensors, stores the data to the internal buffer and caches in S3 bucket. One Lambda analyzes incoming data and fires off the next step. The next step ranges from one simple Lambda, like e.g., a simple call for updated foreign currency arithmetic; to more sophisticated sequence of serverless functions, e.g., to (a) configure and (b) run a EMR/Spark application process the S3 data; once data is processed, yet another Lambda shuts EMR/Spark). Read more
Better Devops Division of LaborWhen we come across an organization struggling to get Devops off the whiteboard and into production, it’s often the case that developers are slowed down by having to wrestle with infrastructure decisions. They don’t have complete visibility into its impact on the operating platform, what’s behind the APIs they called. On the other side, the infrastructure team has to contend with the unintended side effects of developers choices on scalability, availability, and performance. You don’t just have to take our word for it. AWS commissioned a study of the impact of serverless application development, and as you might imagine, the study shows it can save a lot of money. What we found more interesting is what some of the survey participants said:
- “[Why AWS Lambda?] … On the business side, it was taking too long to add new capacity to support services. Everything needed to go through layers of processes. The business needed compute that’s ready right away, and AWS Serverless Platform was ideal for this.”
- “We worked with Docker and some other traditional server-based management tools but opted to go with the AWS Serverless Platform. … The biggest factors in that decision were much lower overhead in terms of operating costs and the ability for anyone on our team to do anything they needed to do on the platform.”