Timedora

Designing Serverless Applications

A practical guide to composing managed services, event-driven functions, messaging, workflows, and reliability practices into serverless applications.

Foundations: Events, Functions, and Storage

What “” means

A application is assembled from managed services—such as functions, databases, object storage, APIs, message brokers, and engines. “” does not mean that no servers exist. Rather, the cloud provider manages much of the infrastructure and scales resources according to the services’ configured behavior. This lets a team focus more on application behavior than on provisioning and maintaining servers.

Events connect services to focused work

An records something that happened, such as an HTTP request, a file upload, or an order being placed. An source produces or delivers that . An -driven function runs in response and performs a focused task. Delivery can be direct (push) or the platform can poll a or stream for records (pull).

The function should validate and interpret the input: formats vary by source, so it is unsafe to assume every has the same shape. A useful design principle is to keep each function focused on one clear piece of business logic.

Choose storage for the data

Keep functions stateless: store durable application data in a database or object store, not in a function’s temporary memory. This lets independently running function instances work with application data and makes retries or scaling easier to manage. Object storage is suited to files such as images and documents; databases are suited to structured records and queries.

For example, a photo-upload application can keep original images in object storage and save image metadata in a database. When an image is created, that can trigger a function to generate a thumbnail. The file, its structured description, and the processing task each have a fitting role in this design.

APIs and Messaging: Immediate Responses and Buffered Work

APIs: immediate result or acknowledgment

An exposes application operations to clients. An gateway can accept an HTTP request, apply controls such as routing and authorization, and invoke a function. The function can validate the request, access storage, and return a response.

Choose the response pattern according to what the caller needs. If the caller needs an immediate result, use a synchronous : the request is handled and a response is returned as part of that interaction. If the work takes longer, the can return an acknowledgment and the work can continue asynchronously. In that case, the acknowledgment does not mean the task has finished.

Queues buffer work

A temporarily holds messages between producers and consumers. It is useful when work can happen later, when consumers are slower than producers, or when temporary failures should not lose work. Because messages can wait in the , it can smooth bursts and reduce direct dependencies between the producer and consumer. The tradeoff is that processing may finish after the original request has returned.

For example, an order can put a payment task on a and respond promptly. A separate function processes the payment later. The client-facing response and the completion of the task are therefore distinct events.

buses and pub-sub

An bus routes events to consumers according to rules. messaging can distribute an to multiple subscribers. Both patterns let producers publish facts without having to know every consumer. In common patterns, a distributes work among competing consumers, while pub-sub delivers a copy to each subscriber. These are typical distinctions, not guarantees that apply identically to every service or configuration.

Choosing an interaction or messaging pattern
PatternRoleTypical behavior
Synchronous APIServes a client requestReturns a result when the caller needs an immediate response.
Asynchronous APIStarts longer-running workCan acknowledge the request before processing finishes.
QueueBuffers messages between producer and consumerCommonly distributes work among competing consumers.
Event bus or pub-subRoutes or distributes eventsPub-sub commonly delivers a copy to each subscriber.
Common roles and patterns; queue and pub-sub delivery descriptions are typical patterns, not universal guarantees.

Coordinating Multi-Step Processes

Coordinate the steps, not just the functions

A coordinates several steps, including their order, branching, retries, and error handling. This is useful when an application process involves more than one focused task.

There are two broad ways to coordinate such work. In , services react to events and publish further events. This can be flexible, but it may be harder to see the process as a whole. In , a service explicitly tracks and coordinates the steps. is often a better fit when the process has several branches, failure paths, or long-running state.

Consider the order example. The validates an order, reserves inventory, requests payment, and sends confirmation if payment succeeds. If payment fails, it can instead release the reserved inventory and report the failure. The failure branch matters: without it, inventory might remain reserved even though the payment did not succeed.

Keeping this coordination in a engine avoids placing the entire process inside one large function or scattering fragile coordination logic across many functions.

Reliability, Security, and Operations

Design for retries and duplicate delivery

-driven systems must account for retries and duplicate delivery. A function should be : if the same is processed again, it should not cause an unintended second effect. For example, a repeated payment must not charge a customer twice. A stable or transaction identifier can help the function detect work already completed, and state changes should be safe to repeat.

This does not mean failures can be ignored. Instead, plan how a function validates its input, how long it may run, and what should happen when processing fails. Validate data and handle missing or unexpected fields. Set timeouts and retry policies appropriate to the operation. Messages that repeatedly fail can be routed to a for inspection.

Make operations observable and access limited

Monitor function errors, depth, latency, and failures. These measures help reveal problems in different parts of the system—for example, errors in processing, accumulating queued work, or delays in a .

Apply least-privilege permissions so each function can access only the resources it needs. Also avoid unnecessary service-to-service calls: each network boundary can add latency and another possible failure mode. Together, these practices address reliability, security, and operational visibility without assuming that retries or independent services will always succeed.

Putting the Pieces Together: Document Processing

Trace a document from upload to result

A document-processing example shows how the service roles fit together:

  1. A client requests an upload through an and receives permission or a destination for the file.

  2. The client stores the file in object storage.

  3. The storage service emits an , which starts a processing .

  4. A function extracts metadata and places a processing task on a .

  5. A consumer processes the task and stores the result in a database.

  6. The or another -driven function records completion and notifies the client.

The choices follow the kind of work and data involved: object storage holds the file, the buffers a processing task, and the database holds the result. The function performs focused processing, while the coordinates the steps. The final notification communicates completion; it is distinct from the initial upload authorization.

  • : A service that preserves application data beyond a function’s temporary memory.

  • : A permissions approach that limits access to what is necessary for a function’s task.