AWS Lambda Essential2014年〜
A serverless compute service that runs code without server management
What It Does
AWS Lambda is a serverless compute service that lets you run code without provisioning or managing servers. Code is automatically executed in response to events (HTTP requests, file uploads, database changes, etc.), and you're charged only for the execution time. It supports major languages including Python, Node.js, Java, Go, and .NET.
Use Cases
Used for API backend processing, image resizing on S3 file uploads, data processing triggered by DynamoDB changes, scheduled batch processing, IoT device data processing, and all kinds of event-driven workloads.
Everyday Analogy
Think of it like a vending machine. Press a button (event occurs) and a drink comes out (code executes). The electricity and maintenance of the vending machine (server management) are handled by the vendor (AWS). No charges are incurred while no buttons are being pressed.
What Is Lambda?
AWS Lambda is the most widely used serverless service on AWS. You upload units of code called functions, and they're automatically executed when events occur. Even if thousands of requests come in simultaneously, it scales automatically, and when there are no requests, the cost is zero.
Event Sources and Triggers
Lambda can be triggered by events from over 200 AWS services and SaaS applications. Common triggers include HTTP requests from API Gateway, object uploads to S3, data changes in DynamoDB Streams, messages in SQS queues, and scheduled events from EventBridge. By combining these, you can build serverless architectures.
Pricing and Limits
Lambda pricing is calculated based on two factors: request count and execution duration (GB-seconds). The free tier includes 1 million requests and 400,000 GB-seconds per month, always free. Maximum execution time per invocation is 15 minutes, and memory can be configured up to 10,240 MB. The deployment package size limit is 50 MB compressed and 250 MB uncompressed, but using container images supports up to 10 GB. For detailed information on pricing and limits, related books on Amazon also provide explanations.
Getting Started
Click 'Create function' in the Lambda console and select a runtime (Python, Node.js, etc.). Write code in the console editor and verify the results with the 'Test' button. Set up API Gateway as a trigger, and you'll have an HTTP API backend ready in minutes.
Things to Watch Out For
- Maximum execution time per invocation is 15 minutes. For longer-running processes, consider Step Functions or ECS/Fargate
- Cold starts (initial startup delay) may occur. Consider Provisioned Concurrency if latency is critical
- The free tier includes 1 million requests and 400,000 GB-seconds per month, always free