Meet the invisible waiter: "AWS Lambda in Action"

Cv Akhilesh2Cv Akhilesh2
2 min read

Imagine you walk into a smart restaurant. There are no visible waiters. You sit down, tap a button on the table, and poof!—a waiter appears, takes your order, delivers your food, and disappears. You didn’t see anyone waiting around, wasting time or energy. Efficient, right?

That’s AWS Lambda.

What is AWS Lambda?

AWS Lambda is a serverless compute service. You write your code, upload it to Lambda, and it runs only when needed—like our invisible waiter. You don’t manage servers, don’t worry about scaling, and only pay when it works.

The Invisible Waiter in the Real World (Example)

Scenario: Real-Time Image Resizer for a Blog

Let’s say you run a photography blog. When users upload large images, you want them automatically resized into thumbnails, previews, and full-view versions—instantly, without slowing down your website.

Here’s how AWS Lambda makes this magic happen:

1. A user uploads an image to an S3 bucket.

2. That triggers an event.

3. AWS Lambda hears the event and runs your image processing code.

4. It resizes the image into 3 sizes and uploads them to respective folders in S3.

5. Done. Lambda disappears.

No need for a backend server running 24/7. Just event → function → result.

Why It’s Cool

Auto-scaling: Got 100 uploads at once? 100 waiters (Lambda functions) appear, work, and disappear.

No idle costs: You’re not charged unless it’s doing something.

Simple Dev Flow: Write short, focused functions that do one thing well.

Behind the Scenes (a peek for techies)

The coding part

import boto3

from PIL import Image

import io

s3 = boto3.client('s3')

def lambda_handler(event, context):

bucket = event['Records'][0]['s3']['bucket']['name']

key = event['Records'][0]['s3']['object']['key']

response = s3.get_object(Bucket=bucket, Key=key)

image = Image.open(response['Body'])

sizes = {'thumbnail': (100, 100), 'preview': (500, 500)}

for name, size in sizes.items():

resized = image.copy()

resized.thumbnail(size)

buffer = io.BytesIO()

resized.save(buffer, 'JPEG')

buffer.seek(0)

new_key = f"{name}/{key}"

s3.put_object(Bucket=bucket, Key=new_key, Body=buffer)

Wrap Up

AWS Lambda is like having an army of invisible helpers that spring into action when something happens. It’s cost-efficient, lightning-fast, and perfect for event-driven tasks like image processing, notifications, real-time analytics, and more.

So next time you want to automate a tiny task without spinning up a whole server, call on your invisible waiter—AWS Lambda

10
Subscribe to my newsletter

Read articles from Cv Akhilesh2 directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Cv Akhilesh2
Cv Akhilesh2