Nguyen Le Phong

Serverless Trade-offs: What You Hand Over and What You Still Own

Serverless takes servers off your plate and moves work to retries, limits, cold starts and the bill.

Your team ships its first serverless workflow on a Friday afternoon. A file lands in object storage, a function resizes it, a message goes onto a queue and a second function sends the email. No servers to patch, no autoscaling group to tune, and the bill for the first week is a few cents. It feels great. On Monday someone asks why a few customers got the same email three times, and why one function's logs say "Task timed out" with no other clue.

Both of those Monday questions come from the same place. Serverless takes a lot of work off your plate, and it also moves some work to places you might not be looking. This post goes through what you hand over, what you keep, and how to tell when the trade is a good one. The numbers come from AWS Lambda's documentation (checked in November 2026) because it's the most widely used example, but the same trade-offs show up on Google Cloud Run functions, Azure Functions and the rest.

An engineer looks over a freshly deployed serverless workflow in the evening, with dashboards, a queue and event-driven services on screen.
Deploy day looks tidy: events, functions and no machines in sight. Monday's questions are where the real design work starts.

What you hand over, and what you keep

Mike Roberts' long article on Serverless Architectures on martinfowler.com splits the idea in two. Backend as a Service (BaaS) is hosted building blocks you call directly: auth, databases, storage, queues. Functions as a Service (FaaS) is your own code running in stateless, short-lived containers that the provider starts when an event arrives. Most "serverless" systems mix both.

The servers still exist. The provider runs the machines, patches the OS and runtime, replaces broken hardware and adds capacity when traffic spikes. Your team writes code that reacts to business events: an upload finished, a payment webhook came in, a message reached the queue, the nightly schedule fired.

Roberts is clear about the other half: "Serverless doesn't mean 'No Ops'." You still own monitoring, deployment, security and on-call. The list of things you keep is shorter, and every item on it matters more:

  • Event contracts: what each message looks like and how it changes over time.
  • Failure handling: retries, duplicates, dead-letter queues.
  • Permissions: which function can touch which resource.
  • Observability: following one request across functions and queues.
  • Cost: watching a bill that scales with every call.

Where serverless fits well

The clearest win is focus. A small team can run a useful workflow without maintaining a cluster or paying for idle machines overnight. Functions scale from zero when traffic shows up and go back to zero when it leaves, so spiky or irregular workloads fit nicely: internal tools, scheduled jobs, webhooks, file processing, prototypes and glue between managed services.

There's also a design benefit. Functions are small and triggered by events, so you end up naming your boundaries: one function validates the webhook, one transforms the document, one sends the notification. When that goes well, the system reads like a list of small jobs connected by events, and each piece is easy to change on its own. If you want the bigger picture on event-driven design, the event-driven architecture post covers it.

Two engineers draw functions, queues, webhooks and permissions on a whiteboard, grouping managed services into clear boundaries.
The design work is still there. It sits in the event contracts, permissions and retry rules between the boxes.

The limits are part of the design

Every FaaS platform puts hard edges around a function. Here are a few of Lambda's, from its quotas page:

LimitDefault valueWhat it means for your design
Function timeout15 minutesLong jobs need splitting into steps, or a container.
Memory128 MB to 10,240 MBCPU scales with memory, so a slow function sometimes just needs more of it.
Payload6 MB synchronous, 1 MB asynchronousPass a pointer to the file in storage, not the file itself.
Concurrent executions1,000 per Region (can be raised)One busy function can starve the others in the same account.
Deployment package250 MB unzipped, 10 GB as a container imageHeavy dependencies push you toward container images.

Limits like these keep functions small, which is often a good thing. They hurt when the workload wants to run for a long time, hold state in memory, keep long-lived connections open or respond with steady low latency. A video pipeline can work well if you split it into steps. A collaborative editor full of WebSocket sessions or a service that keeps a large model in memory will keep running into the platform's edges.

Cold starts: rare, but not free

When no warm execution environment is ready, the platform has to download your code, start the runtime and run your initialization code before the handler. AWS's execution environment docs say cold starts typically happen in under 1% of invocations and take from under 100 ms to over a second. They're more common in dev and test functions, which get called less often.

For a background job that's noise. For a login endpoint, a one-second pause now and then is something users feel. Treat latency as a product decision: which endpoints have a budget, and how strict is it? Then pick a fix that matches:

  • Trim the package and import only what you use. Init code is the biggest part of a cold start.
  • Create clients and connections outside the handler so warm invocations reuse them.
  • Use SnapStart where your runtime supports it (Java, Python and .NET at the time of writing). It restores from a snapshot of an already initialized environment.
  • Pay for provisioned concurrency when you need predictable start times. It keeps a set number of environments warm, and you pay for them whether they're busy or not.

Retries mean duplicates, so plan for them

Back to the triple email from Monday. When an asynchronous Lambda invocation fails, Lambda by default tries it two more times. The same page warns that your function can receive the same event more than once even when nothing failed, because the internal queue is eventually consistent. Queue-triggered functions behave similarly. So every handler with a side effect (charge a card, send an email, write a row) needs to be idempotent: running it twice should have the same effect as running it once.

A minimal version records the event ID with a conditional write before doing the work:

import { DynamoDBClient, PutItemCommand } from '@aws-sdk/client-dynamodb'
import { sendReceipt } from './receipts.js'

// Created once per execution environment, reused on warm starts
const db = new DynamoDBClient({})

export const handler = async (event) => {
  for (const record of event.Records) {
    const { orderId } = JSON.parse(record.body)
    try {
      await db.send(new PutItemCommand({
        TableName: 'processed-orders',
        Item: { orderId: { S: orderId } },
        ConditionExpression: 'attribute_not_exists(orderId)',
      }))
    } catch (err) {
      if (err.name === 'ConditionalCheckFailedException') continue // seen it already
      throw err
    }
    await sendReceipt(orderId)
  }
}

This version has a known gap: if the function crashes between the write and the email, the retry skips that order and the receipt never goes out. For anything where that matters, use a library that tracks "in progress" and "completed" separately and expires stuck records, like the Powertools for AWS Lambda idempotency utility. The general retry and idempotency toolkit is in the resilience post.

Cost has two faces

Serverless can be very cheap, because you pay per request and per unit of compute time and nothing for idle hours. It can also surprise you, because every invocation, message, read, write, log line and retry has a price. A verbose debug log that looked harmless in staging gets multiplied by production traffic.

The scariest version is a loop: a function writes to the same queue or bucket that triggers it. AWS added recursive loop detection for this. It's on by default and stops the chain after about 16 invocations, but only for loops through SQS, S3, SNS and EventBridge custom buses, plus loops made purely of Lambda functions. A loop that goes through a database, for example, won't be caught. AWS's own advice on that page is to set CloudWatch alarms on invocations and concurrency and a billing alarm on spend.

So the useful question is whether the cost model fits your traffic shape, and whether you'll see a spike within hours instead of at the end of the month.

Two engineers look at invocation counts, retry rates and a cloud cost dashboard together across several monitors.
Invocations, retries, log volume and cost on one screen. That's how you judge the trade, with numbers instead of the word "managed."

Lock-in is a price, so check it

Roberts lists vendor lock-in as a real drawback: moving from one provider's functions to another usually means changes to tooling, code and architecture. That's worth taking seriously and not worth panicking over. Your database, your queue and your framework all lock you in a little too.

The practical question is where portability actually matters. Keep business logic in plain modules that don't import the cloud SDK, and keep the event-to-function wiring thin. Then a move means rewriting the edges while the core stays put. If the platform saves your team a year of operations work, a higher migration cost later can be a fair price.

How to start without regrets

  • Pick one workflow with clear events and relaxed latency needs: image processing, report generation, webhook intake.
  • Keep each function to one job, and write the event schema down with a version field.
  • Make handlers idempotent before the first retry surprises you.
  • Pass a trace ID through every event and set up dashboards before the first incident. The observability at scale post covers how.
  • Test against the real cloud in staging. Roberts is blunt that integration testing serverless apps is hard, and a local emulator won't reproduce IAM, quotas or the queue's retry behavior.

When to pick something else

Serverless fits wellLook at containers or VMs
Spiky or unpredictable traffic, long idle stretchesSteady, high traffic all day, where a reserved machine is cheaper
Short, stateless jobs triggered by eventsLong-running work, in-memory state, long-lived connections
Small team that wants a small ops surfaceTeam that needs control over the runtime, network or hardware
Background work that can absorb an occasional cold startStrict, steady low-latency requirements on every request

Plenty of real systems mix both: functions for event workflows and glue, containers for long-running services, a managed database underneath and a few scheduled jobs where one function is exactly enough.

Try this week

  • List every function that has a side effect and check that each one handles a duplicate event safely.
  • Look up your platform's timeout, payload and concurrency limits and compare them to your largest real job.
  • Set a billing alarm and an alarm on invocation count if you don't have them yet.
  • Check your p99 latency on user-facing functions and decide whether cold starts actually matter there.
  • Next time someone says "let's make it serverless," ask which responsibilities you're handing over and which ones get more important because of it.
What did you think?

Frequently asked questions

Does serverless mean there are no servers or no ops work?
No. The provider runs and patches the machines, but you still own monitoring, deployment, security, on-call, event contracts, retries and cost. Mike Roberts' Serverless Architectures article puts it plainly: serverless doesn't mean no ops.
How often do Lambda cold starts happen?
AWS's documentation says cold starts typically happen in under 1% of invocations and take from under 100 ms to over a second. They are more common in dev and test functions that get called less often. SnapStart, smaller packages and provisioned concurrency reduce them.
Why does my serverless function process the same event twice?
Lambda retries a failed asynchronous invocation two more times by default, and AWS notes a function can receive the same event more than once even without an error. Make every handler with a side effect idempotent, for example by recording the event ID with a conditional write.
What are the main AWS Lambda limits to design around?
A 15-minute timeout, 128 MB to 10,240 MB of memory, 6 MB payloads for synchronous calls and 1 MB for asynchronous ones, and a default of 1,000 concurrent executions per Region that can be raised.
When should I avoid serverless?
When the workload runs for a long time, keeps state in memory or long-lived connections, needs steady low latency on every request, or has steady high traffic where a reserved machine is cheaper. Containers or VMs usually fit those better.