Engineering / Engineering journal

Serverless vs Containers for a Growing Product

Serverless is cheap and effortless until load becomes steady; containers are predictable but ask more of your team. How to choose, and why most products end up using both.

Sylantix Engineering Team7 min read
A rackmount server beside a laptop showing deployment logs.
Sylantix / Engineering journalArchitecture · Hosting · DevOps
In this article 8 sections
TL;DR

Key takeaways

  • Serverless bills per invocation, so it is cheap at low or spiky load and can get expensive once traffic is steady.
  • Containers cost money while idle but give predictable performance, long-running processes and easier local debugging.
  • Cold starts, execution time limits and provider-specific glue are the real constraints of serverless, not the price.
  • A common end state: containers for the core API, functions for spiky background jobs and event handlers.

How the workload affects the choice

Short, occasional jobs and an API serving steady traffic place different demands on hosting. Serverless functions can reduce server administration, while containers give you more control over long-running processes and resource allocation.

The right mix can change as usage grows. Compare traffic patterns, execution limits, debugging and the work your team is prepared to own.

What each model means day to day

Serverless functions

You write a function, the provider runs it when an event arrives: an HTTP request, a message on a queue, a file landing in storage, a scheduled trigger. You do not manage machines, operating systems or scaling. Each invocation is billed for the time and memory it uses, and when nothing happens, you pay nothing.

The trade is control. Functions run with limits on execution time and memory, start fresh when they have been idle, and depend on the provider's way of wiring events, permissions and configuration together.

Containers

You package your application and its dependencies into a container image and run it on a platform that keeps it alive: a managed container service, a Kubernetes cluster or a simpler hosting platform. The process stays running, holds connections open and handles many requests over its lifetime.

You pay for the capacity you reserve, whether it is busy or not. In return you get a long-running process that behaves the same on your laptop, in staging and in production.

Cost shape, not price

Comparing list prices is misleading. What matters is the shape of the cost curve against your traffic.

Serverless cost rises in a straight line with usage. At low or bursty load that is a gift: a product with a few hundred requests a day, or a reporting job that runs once a night, costs almost nothing. As traffic becomes steady and high, the same straight line keeps climbing, and at some point paying per invocation costs more than keeping a few containers busy around the clock.

Container cost moves in steps. You pay for a baseline even at night, then add capacity as load grows. At low traffic that baseline is wasted money. At steady traffic the containers are well utilized and the cost per request falls.

So the honest summary is simple. Spiky, unpredictable or low traffic favors serverless. Steady, sustained traffic favors containers. Where your product sits today, and where it will sit in a year, matters more than any benchmark.

The constraints that bite in practice

Cold starts

A function that has been idle needs to start before it can respond. For a background job nobody waits on, that delay is irrelevant. For a user-facing API on a quiet product, it means the first request after a lull feels slow. There are mitigations, such as keeping functions warm or reserving capacity, but each one chips away at the "pay only when used" benefit.

Long-running work

Functions have execution time limits. Imports, video processing, large reports and data migrations often run longer than that. You can break them into steps and chain them through queues, and sometimes that is a good design anyway, but it is extra work you would not need in a container that simply keeps running until the job is done.

Connections and state

Each function invocation may run in a fresh environment. Database connections, in-memory caches and websocket sessions do not carry over the way they do in a long-lived process. Relational databases in particular can struggle when hundreds of short-lived functions open connections at once, which usually means adding a connection pooler or a proxy in front.

Local development and debugging

A container runs on a developer's laptop exactly as it runs in production, and a request can be followed through one process with an ordinary debugger. Serverless systems are harder to reproduce locally, because behavior depends on triggers, permissions and managed services that live in the cloud. Emulators help, but teams often end up debugging in a shared cloud environment and reading logs spread across several functions.

Lock-in

Function code itself is portable enough. The glue is not: event triggers, permission policies, provider-specific queues and configuration formats. The more of your architecture lives in that glue, the more expensive it becomes to move. Containers are not lock-in free either, but a container image runs on many platforms with modest changes.

Seeing where the money goes

With containers, cost maps onto a handful of services you can name. With serverless, spend is spread across thousands of invocations, storage triggers and data transfer between managed services. A misconfigured retry or a function that calls itself can run up a bill overnight. Budget alerts, per-function cost tags and sensible concurrency limits are not optional extras on serverless; set them up on the first day, before the first unusual traffic spike arrives.

Team skills count

Serverless shifts work from operations to design. There is less to patch and monitor, but someone has to understand event flows, permission policies and the limits of the platform. Containers ask for a different skill set: building images, configuring health checks, planning capacity and keeping the base images updated.

A small team without anyone who enjoys infrastructure often moves faster on serverless or on a managed container platform that hides most of the cluster. A team that already runs containers comfortably gains little by splitting everything into functions.

Mixing both is normal

The choice is rarely all or nothing. A setup that works well in growing products:

  • the core API and web backend run in containers, because they handle steady traffic, keep database connections warm and are easy to debug
  • background jobs that arrive in bursts, such as image resizing, webhook handling or document processing, run as functions triggered by queues or storage events
  • scheduled tasks that run for a few minutes a day run as functions on a timer instead of keeping a worker alive

This mirrors the broader architecture question. A single well-structured application with a few side services for spiky work is usually a healthier place to be than dozens of tiny pieces, for the same reasons discussed in monolith vs microservices.

A decision checklist

Answer these for the part of the system you are deciding on, not for the whole product at once:

  1. Is the traffic steady through the day, or does it come in bursts with long quiet periods?
  2. Can any single task run longer than the platform's execution limit?
  3. Does a user wait for the response, so that a cold start would be noticeable?
  4. Does the component hold connections, caches or sessions that benefit from a long-lived process?
  5. How much of the design would depend on provider-specific triggers and configuration?
  6. Who on the team will operate it, and which model are they comfortable debugging at night?

Mostly bursty, short, background and lightly coupled points to functions. Mostly steady, long-running, user-facing and stateful points to containers. Mixed answers point to splitting the component along those lines.

Compare traffic and job duration

Pull last month's traffic for your backend and plot requests per hour. If the graph is flat with a daily bump, your core API is a container workload; if it is mostly empty with sharp spikes, functions will be cheaper and simpler. Then list your background jobs with their run time and frequency, and move the short, bursty ones to functions first. Once the split is made, move traffic gradually: feature flags and gradual rollouts let you send a small share of users to the new path and stop quickly if it misbehaves. Our cloud and DevOps page explains how we review infrastructure like this.

Facing this in your own product?

Describe your situation in a few sentences. Our engineering team replies within 24-48 hours on business days, and the first 30-minute consultation is free.

Sylantix Engineering Team

Written by the senior engineers who build these systems for clients: backends, AI features, mobile apps and the infrastructure under them. Questions about your own case go straight to them.

About the team →