Build applications without thinking about servers: serverless architecture with scale-to-zero, event-driven behavior, and per-execution billing in milliseconds. This episode covers event triggers, a Node.js Lambda function example, and a comparison of Lambda, Cloud Functions, Cloud Run, and Azure Functions.

In episode 10 we learned to store non-relational data and accelerate it with caches. But all of that still runs on servers whose capacity you must calculate, whose uptime you must maintain, and which you must patch. What if all that work was removed — you just write code, and the cloud handles the rest?
Episode 11 opens up the serverless paradigm: architecture in which a server is no longer a unit you think about. We'll discuss the scale-to-zero and pay-per-execution principles, event-driven architecture, types of event triggers, an example Lambda function in Node.js, how to deploy it via the CLI, and the FaaS service map on AWS, GCP, and Azure.
The name "serverless" is misleading — servers still exist, they're just no longer your responsibility. The provider supplies an execution environment hidden behind the scenes, and you only interact with two things: the function code and the events that trigger it.
Three properties set serverless apart from everything we've discussed before:
Tip
The best analogy is a ride-hailing service versus hiring a car with a driver. Hiring a driver (VM) means paying in full while hired, even if the car sits idle. Serverless is like ordering a ride only when needed: arrives quickly when called, leaves when done, and you pay only for the distance traveled. If your traffic is sporadic — sometimes busy, sometimes quiet — the ride-hailing option is far cheaper; if you serve constant traffic, a private driver can be cheaper.
FaaS is the purest form of serverless: one function, one response, no visible server. There are two technical properties you must understand from the start:
Important
This stateless property is what most often trips up new developers. Never store user sessions, temporary files, or mutable global variables inside a serverless function. If you need data to survive between executions, store it outside — this is why episodes 9 and 10 (databases and caches) are the natural prerequisites before diving into serverless.
A serverless function has no on button — it wakes only when an event arrives. The four most common trigger patterns:
| Trigger | Example | Flow |
|---|---|---|
| HTTP API | REST endpoint | Browser calls a URL, the function executes and responds |
| New file | Object storage | User uploads a file, the function processes it (resize, scan) |
| Database change | Stream or CDC | A new row is written, the function responds (notification, aggregation) |
| Queue message | Queue or topic | Service A sends a message, service B processes it asynchronously |
Imagine a photo management system: a user uploads an image (file event), a function is triggered to create a thumbnail and store it, then sends a message to a queue, which triggers another function to send a notification. No server runs continuously — the whole pipeline wakes up only when needed.
Note
One principle of good architecture: make each function do only one thing. A function that handles thumbnails, resizing, and notifications at once is hard to test, hard to scale, and costs more. Small, focused, and never sharing state — this is the style recommended by all providers.
A Lambda function exports a handler. The following example receives an HTTP request, reads the name parameter, and returns JSON:
export const handler = async (event) => {
const name = event.queryStringParameters?.name ?? "dunia";
return {
statusCode: 200,
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
message: `Halo, ${name}!`
})
};
};Notice the structure of the incoming event: for an HTTP trigger, it carries the method, path, headers, query string, and body. Different triggers form different events — an event from a file upload contains the bucket name and object, an event from a queue contains a list of messages. The same function can be attached to various triggers.
Once the handler is ready, the function is created via aws lambda create-function:
aws lambda create-function \
--function-name hello-cloud \
--runtime nodejs20.x \
--role arn:aws:iam::123456789012:role/lambda-basic-execution \
--handler index.handler \
--zip-file fileb://handler.zipThe important flags: --runtime determines the language version, --handler index.handler points to the file index.js with a function named handler, --role is the IAM role giving the function permission to run (for example, to read a DynamoDB table), and --zip-file sends the packaged code.
Caution
--role isn't just any option — it's the security key. A Lambda function runs with IAM permissions just like a VM: if the role is too broad, an exposed function can access resources it shouldn't. The least privilege principle from episode 4 applies here equally — give the role only the permissions that function genuinely needs.
| Need | AWS | GCP | Azure |
|---|---|---|---|
| Function as a Service | Lambda | Cloud Functions | Azure Functions |
| Serverless container | - | Cloud Run | Azure Container Apps |
| Billing basis | Per request and duration (GB-s) | Per request and duration | Per execution and duration |
The concept is identical across providers: one function, event triggers, automatic scaling, and per-execution billing. GCP and Azure also offer an interesting variant: Cloud Run and Azure Container Apps run containers that can scale to zero — a kind of bridge toward episode 12's topic — still billing per usage but not constrained to a function shape.
Tip
Choose between functions and serverless containers based on need: functions for glue logic, event pipelines, and simple APIs; serverless containers for complete applications with heavy dependencies or full frameworks that are awkward to force into a function shape.
Serverless isn't the answer to everything. Consider when it's the right time to use it:
Serverless shifts complexity from operations to architecture. You no longer think about patching and scaling, but you must think in terms of events, external state, and execution duration limits.
In this episode 11 you understood the serverless foundations: scale-to-zero, which stops execution and billing when there's no event, event-driven architecture with four main trigger patterns — HTTP API, file upload, database changes, and queue messages — and pay-per-execution, which bills per millisecond. You also saw an example Node.js Lambda function and how to deploy it via aws lambda create-function, plus the service map of Lambda, Cloud Functions, and Azure Functions.
The keys to take away:
Serverless functions are ideal for small pieces of logic. What if you need full flexibility over your application — any dependency, long-running processes, its own port — yet still want to run it in a portable, scalable way? Episode 12 answers that: Managed Container & Kubernetes Services — the modern standard for packaging, shipping, and orchestrating applications.