Serverless vs containers: how to run your application

How serverless functions and containers differ in cost, scaling, control and operations, and how to choose the right hosting model for your app.

By the UK Technology Hub teamPublished 4 minute read

The short answer

Serverless functions run your code on demand, scale automatically and charge only for usage, with no servers to manage, which suits APIs, webhooks and spiky workloads. Containers package your application with its environment and run it continuously on platforms you configure, giving more control, consistent performance and portability. Many systems use both: serverless for event-driven tasks and containers for core services.

Once your application is built, it needs somewhere to run. Two of the most popular modern approaches are serverless functions and containers. Each removes some of the pain of traditional servers in different ways.

Serverless

With serverless, you upload functions and the cloud provider runs them when triggered, by an HTTP request, a schedule, a file upload or a message. You don't manage servers, and you typically pay per request and execution time.

Examples: AWS Lambda, Google Cloud Functions and Cloud Run functions, Azure Functions, and functions built into platforms like Vercel, Netlify and Cloudflare.

Containers

A container packages your application and everything it needs into an image that runs the same way anywhere. Containers run on platforms such as Kubernetes, managed container services from cloud providers, or simpler platforms that run containers for you.

Examples: Docker images on AWS ECS or Fargate, Google Cloud Run, Azure Container Apps, Kubernetes clusters.

Comparison

Serverless functionsContainers
ManagementMinimalMore, unless using a managed platform
ScalingAutomatic, including to zeroConfigurable; some platforms scale to zero
Cost modelPer request and durationPer running resources over time
Cold startsPossible delays after idleUsually none if kept running
Execution limitsTime and memory limitsFew limits
Long-running tasksNot suitedWell suited
PortabilityProvider-specific featuresHigh
Local developmentCan be fiddlyConsistent with production

When serverless fits best

  • APIs with variable or low traffic.
  • Webhooks and integrations. Our guide to webhooks explains how these events work.
  • Form handling and email sending.
  • Scheduled jobs and lightweight automation.
  • Image processing triggered by uploads.
  • Prototypes and MVPs.

When containers fit best

  • Long-running services and background workers.
  • Consistent high traffic, where per-request pricing becomes expensive.
  • Applications needing specific runtimes, libraries or system access.
  • WebSocket servers and real-time services.
  • Teams wanting portability across clouds or on-premises.

Cost considerations

Serverless is often cheaper at low or unpredictable volumes because you pay nothing when idle. At high, steady volumes, containers can be more cost-effective. Model your expected usage on both, including data transfer and database costs.

Operations and monitoring

Both need logging, monitoring, alerting and security updates. Serverless reduces infrastructure work but can make distributed debugging harder. Containers give more control but need image updates, scaling configuration and orchestration knowledge, unless you use a managed container platform.

Vendor lock-in

Serverless functions often use provider-specific triggers and services. Containers are more portable. You can reduce lock-in with clean architecture, separating business logic from provider-specific code.

Choosing a cloud

Each major cloud offers both models with different strengths. Our comparison of AWS, Azure and Google Cloud covers the providers.

Combining both

A common pattern: core API and services run in containers, while serverless functions handle events, scheduled tasks and integrations. Managed container platforms that scale to zero also blur the line.

A worked example

Imagine an online booking service. The main API, which handles bookings, accounts and availability, runs in containers because traffic is steady and requests need consistent performance. Serverless functions handle tasks triggered by events: sending confirmation emails, processing uploaded documents, syncing with calendars and generating nightly reports. This combination keeps the core predictable while paying only for occasional tasks when they run.

Security considerations

Both models need least-privilege access, secure secret management and up-to-date dependencies. Serverless functions should have narrowly scoped permissions for the resources they use. Containers need regularly updated base images and vulnerability scanning. In both cases, centralised logging and monitoring help detect problems quickly.

Questions to ask

  • How predictable is your traffic?
  • Do any tasks run longer than serverless time limits?
  • How important is portability between providers?
  • What operations skills does your team have?

Start simple

For many new projects, a managed platform that handles deployment, scaling and HTTPS is the best starting point. You can adopt more specialised infrastructure later as needs become clear.

Revisit the decision as traffic patterns and team skills change over time.

How we help

Our web app development team designs hosting architectures using serverless, containers or both. Our app development service plans for cost and scale, and our maintenance and support plans include monitoring and updates.

Frequently asked questions

Is serverless cheaper than containers?

Often at low or variable traffic. At high, steady traffic, containers can be cheaper. Model your own usage.

What is a cold start?

A delay when a serverless function runs after being idle, while the provider starts a new instance.

Do I need Kubernetes to use containers?

No. Managed container services run containers without you operating Kubernetes yourself.

This guide is general information, not legal, tax or financial advice, and details such as prices, features and rules can change. Product and company names mentioned are trademarks of their respective owners and are used only to identify those products; UK Technology Hub is not affiliated with or endorsed by them.

Related guides

All comparisons guides