Serverless applications with Lambda: 5 use cases
- AWS Lambda News VPC peering
AWS Lambda is the serverless computing service aimed at powering up applications. The cloud architects and developers can use this service for various use cases, and we list them below.
AWS Lambda is one of the most important additions to the AWS offers, as it signifies the next level of developer interaction with the infrastructure. This service literally allows the developers to use the AWS infrastructure without ever looking under the hood — Lambda deploys and manages the required infrastructure, monitors the server health, logs the code execution and provides detailed statistics. This might seem like a PaaS, yet there are some crucial differences:
- Pricing model
- Unlimited scalability of parallel executions
- Native multi-language support
AWS Lambda pricing model is “pay as you go”, so the customers pay only for the computing resources used. This makes the service very cost-efficient, not to mention a free trial period. In fact, the users pay for the used memory, the number of processed code requests and the code execution time rounded up by 100 milliseconds. Just compare it with the hourly EC2 billing rate and witness the granularity and level of control available when using AWS Lambda.
Instead of 24/7 availability common for IaaS, PaaS and SaaS cloud pyramid layers, AWS Lambda is event-driven. The code executes only when it’s needed and consumes zero resources when not triggered. Obviously, this is a huge benefit for applications that are quiet for a long time and then have to meet the demand for resources during the peaks of usage.
Lambda has a setting called the “Number of concurrent requests”, which allows it to scale nearly instantly to a huge number of parallel code execution processes. Downscale is as simple — the unneeded functions stop running automatically once the code is executed.
The developers can use a variety of programming languages with Lambda: Java, Python, Node.JS and other languages through open source frameworks. There are also tools for even more convenient and fast code deployment, namely Apex, Serverless, and Sparta.
Is Lambda perfect then? Well.. not quite, due to some architecture-based limitations.
Lambda limitations… or are they features?
Lambda poses certain limitations for developers to ensure the service is used as intended:
- Disk space maximum is 512 MB for the runtime environment
- Memory volume can vary from 128 to 1536 MB
- Code execution timeout is 5 minutes
- The size of the deployment package is limited to 50 MB, as well as the number of file descriptors
- Request and response body payload size can be 6 MB maximum
- Event request body can be 128 KB at the most
- You must set the limit of concurrent executions for your code
We think these are no limitations, but the wisely designed features of AWS Lambda:
- Setting a limit of concurrent executions allows removing the infinite loops of code
- A function that will run for hours belongs to Elastic Beanstalk, not Lambda
- A deployment package larger than 50 MB must be split to several packages
- If your code exceeds the limits of request payloads, it would be wiser to break it into numerous request endpoints
As you can see, these limitations are actually features of AWS Lambda that prevent using the service to deploy monolithic applications. Such an approach empowers the intended way of using Lambda — for running collections of event-driven stateless microservices. Below we list 5 most prominent use cases of serverless applications with Lambda.
Your website can now run without a server
Here is an example of how a business can go for AWS Lambda and Amazon S3 to host static websites at nearly no cost:
- Deploy the web frontend to S3
- Use CloudFront CDN to provide rapid content delivery
- Setup the web frontend to use API Gateway HTTPS endpoints for sending requests to Lambda
- Lambda works as a backend, deals with the app logic and store the data to relational or non-relational databases, like AWS RDS or DynamoDB
- Isolate your Lambda functions, website code and databases from other networks by setting up an AWS VPC peering.
- As the system components like Lambda, S3, and API Gateway work under PAYG pricing model, you will pay only for the resources actually consumed by your website, not for renting a server to run 24/7 and remain unused for prolonged periods.
You do have to pay for database maintenance on the fixed rate, yet the savings will be huge overall.
Analyze the logs as you go
Just imagine building a Lambda function to harvest the logs from AWS Cloudtrail or other logging apps like Cloudwatch. Lambda watches for the specific triggers and log entries, invoking an SNS notification once such things occur. These notifications can also be easily sent to Slack, Jabber or support systems like Zendesk by calls to their API endpoints in Lambda.
Good old automation of backups and daily routine
Lambda functions can be called on schedule, turning it into a perfect automation tool for repetitive tasks like checking for idle resources, creating backups, generating reports and performing various other routine jobs. Just use boto3 Python libraries and get rid of mundane admin work forever!
Supporting various S3 tasks
If you setup Lambda to listen for S3 event notifications, it can perform any processing of objects stored in S3 buckets. For example, one might use this for image thumbnail generation without the need to worry for sufficient resources, because Lambda scales as much as needed.
Optimization of backend operations
Your website backend must not be the source of interruptions for end-user experience. Lambda can parse the visitor’s input for storing it in a database (or process the input in any other way) while the website renders the next page! The input data will be sent to the required database or application and used in due course, while the visitor enjoys the seamless website experience!
Final thoughts on 5 AWS Lambda use cases for serverless applications
AWS Lambda can and should be one of your main go-to resources for handling repetitive or time-consuming tasks, along with the other heavy-lifting jobs of the data-processing world. It frees your main online services to focus on high-priority frontend tasks, such as responding rapidly to user requests, and it allows you to offload many processes that would otherwise slow down your system.
Should you need to have your IT infrastructure configured to use serverless computing with Lambda — feel free to contact IT Svit. As one of the top-15 MSPs worldwide, we have ample experience with enabling serverless applications based on AWS Lambda.
Feel free to browse through the latest insights and hints on the DevOps, Big Data, Machine Learning and Blockchain from IT Svit!
Wanted: Managed Services for Murdering DevOps
The growth of managed services has provided the developers with cloud-based infrastructure management tools, thus making the DevOps teams obsolete for startups and small businesses.
DevOps in Insurance Industry: Challenges & Real Success Stories
Insurance industry has to be amongst the leaders in adopting the modern technology. Leveraging DevOps in insurance industry can be the disruptive advantage.