• Docs
  • Talk to an expert
Blog
Blog
BlogProductCase studiesNewsInsights
Blog

Task containers vs serverless functions

Task containersdatacost savings
16 November 2026
Share
This post is also available in German and in French.

Note: pricing and features may have changed since publication. Check each provider’s documentation for current details.

Task containers and serverless functions both run code when something triggers them and stop when the work is done. They differ in where that code runs, how long it can run, and what it can reach.

Serverless functions, such as AWS Lambda, Google Cloud Run functions, Azure Functions, Vercel Functions, and Cloudflare Workers, run short, event-driven code on a provider's managed fleet. Most cap a single invocation at under an hour, scale out automatically, and bill per invocation and duration. Limits vary by provider and plan.

Upsun task containers are on-demand containers defined in the same .upsun/config.yaml as the application. Each run starts in the application's environment, reaches that environment's databases and services through relationships, runs for up to 24 hours, and exits. Runs are billed per second at application CPU and memory rates.

How do task containers and serverless functions compare at a glance?

Feature

Upsun task containers

Serverless functions

UnitContainer in .upsun/config.yamlFunction on a provider
Longest run24 hours (1 hour default)Under 1 hour on most plans
TriggersConsole, CLI, or APIHTTP, queues, storage, schedules
Concurrency3 runs by default, then queuedHundreds to thousands
Data accessEnvironment services via relationshipsOver the network, often via VPC setup
HTTP endpointNoneUsually yes
RetriesNone; the caller retriesBuilt in for many event triggers
BillingPer second, app CPU and memory ratesPer invocation plus duration

What are task containers and serverless functions?

Serverless functions

A serverless function is code you deploy to a provider without managing servers. When an event arrives, the provider starts or reuses an execution environment, runs the handler, and may discard the environment afterward. AWS Lambda, Google Cloud Run functions, Azure Functions, Vercel Functions, and Cloudflare Workers all follow this model, each with its own runtimes, limits, and event sources.

Upsun task containers

An Upsun task container is an on-demand container defined under a top-level tasks: key in .upsun/config.yaml. Each task has a runtime type and a run.command. When a task is triggered, Upsun starts the container in the same environment as the app, runs the command, records the result as an activity (pending, in progress, complete, or cancelled), and stops the container. Tasks use the same runtimes as Upsun applications.

Task containers follow the same run-to-completion model as a serverless function: a task is triggered, runs its command, and exits. The difference is where it runs. A task runs inside the Upsun environment, next to the services and data the application already uses.

How do they differ in practice?

How long can each one run?

Most serverless functions have a time limit on each run:

  • AWS Lambda: 15 minutes
  • Google Cloud Run functions: 60 minutes over HTTP, 9 minutes when an event triggers them
  • Azure Functions: no limit on the Flex Consumption plan
  • Vercel Functions: about 13 minutes
  • Cloudflare Workers: 5 minutes of CPU time

An Upsun task runs for up to one hour by default, and you can raise that to 24 hours with the run.timeout setting. When a task reaches its limit, Upsun asks it to stop before shutting it down, so a long job should save its progress when that request arrives.  
 

How are they triggered?

Functions subscribe to HTTP requests, queues, storage changes, and schedulers. Examples include Amazon EventBridge for Lambda, Eventarc for Cloud Run functions, timer triggers for Azure Functions, and Cron Triggers for Cloudflare Workers.

An Upsun task runs when someone starts it in the Console, runs upsun task:run, or sends a POST request to /projects/{project}/environments/{environment}/tasks/{name}/run with optional variables. Upsun cron jobs do not start tasks directly. Upsun's cron tutorial schedules a cron job that calls the tasks API. An application can start a task the same way, for example after a user uploads a file.

How do they reach databases and services?

A Lambda function must run in the same Amazon VPC as an RDS database to connect to it, and AWS recommends RDS Proxy for functions that open and close many short connections. Cloud Run functions and Azure Functions on Flex Consumption offer VPC and virtual network integration to reach private resources.

Upsun tasks use one-way relationships to the environment's services, and connection details appear in the PLATFORM_RELATIONSHIPS variable. Files written to storage mounts and service mounts persist between runs. The instance and tmp mounts reset on every run. Because a task's concurrency is low by default, it opens few database connections at once.

How are they packaged, and how fast do they start?

Lambda accepts zip packages and container images up to 10 GB. Cloud Run functions build from source. Cloudflare Workers run in V8 isolates, which start without booting a container, and a Worker must finish its startup phase within 400 ms. Cold starts on container-based functions vary with package size and runtime.

Upsun tasks are built from the same repository as the application and use the same language runtimes, so a task can reuse the application's code and scripts. Its hooks.build runs during the environment's build phase, and the resulting image is reused across runs instead of being rebuilt each time.  
 

How many runs can happen at once?

Lambda starts with 1,000 concurrent executions per Region, and the quota can be raised. Vercel Functions scale up to 30,000 concurrent executions on Hobby and Pro plans. Cloud Run functions default to 100 maximum instances for HTTP functions, adjustable up to 1,000. 

Upsun task runs execute in parallel up to a default limit of three, and further triggers queue until a slot opens. Upsun's run-to-completion post sets that limit per project, and trial projects have a lower limit. For work that fans out into thousands of parallel jobs, a function platform fits better

What happens when a run fails?

Lambda retries failed asynchronous invocations twice by default and can send failed events to a dead-letter queue or destination. Retries on Cloud Run functions are opt-in for event-driven functions, and Azure Functions retry policies depend on the trigger. 

Upsun records each task run as an activity with a final status. The platform does not retry a failed run, so retries live in the code that triggered it. Upsun also cancels running tasks on an environment before a deploy to that environment, so long tasks should be idempotent and safe to restart.

How isolated is each run?

Lambda runs each execution environment in a Firecracker microVM, and Lambda MicroVMs expose VM-level isolation for running user and AI-generated code. Cloudflare Workers isolate code in V8 isolates.

Upsun tasks use the same LXC-based isolation as applications: Linux namespaces, dropped capabilities, seccomp, cgroup limits, and network isolation. For untrusted code, the tasks docs recommend pairing a task with Bubblewrap, which the team sets up inside the task. Workload authorizations let an application trigger a task and let a task read its environment through the Upsun API, using a token from http://localhost:8200/oauth2/token that lasts 60 seconds by default and up to 900 seconds.

How is each one billed?

Lambda charges per request plus GB-seconds of duration. Vercel Functions on Fluid compute bill active CPU, provisioned memory, and invocations. Cloudflare Workers bill requests and CPU time. Cloud Run functions and Azure Functions Flex Consumption bill per execution and resource use, with optional always-ready instances. 

Upsun bills each task run per second at the same CPU and memory rates as applications. The application and services in the environment are billed as usual, because Upsun applications do not scale to zero. When comparing costs, compare the full monthly bill, including the database, networking, and queue services a function needs to reach the same data.

Which fits each use case?

Use case

Better fit

Handling webhooks and API requestsServerless functions
Reacting to storage or queue eventsServerless functions
Fanning out thousands of parallel jobsServerless functions
Running jobs over an hour on app dataUpsun task containers
Running migrations, imports, and reportsUpsun task containers
Running an AI agent against the app databaseUpsun task containers
Running untrusted, model-generated codeA dedicated sandbox service

Can you use task containers and serverless functions together?

A webhook from a payment provider, for example, can land on a function or on the Upsun app itself. The handler validates the request, starts a task through the API with the event details as variables, and returns a response. The task then runs the import or reconciliation for as long as it needs, up to its timeout.

How do you move a function's work into a task container?

  1. Define the task under tasks: in .upsun/config.yaml, with the same runtime the app uses.
  2. Move the handler's logic into a script the task's run.command calls, and read inputs from variables instead of an event payload.
  3. Add relationships for the databases and services the job needs.
  4. Set run.timeout to cover the longest expected run, up to 86,400 seconds.
  5. Point the existing trigger at the tasks API from the app, a cron job, or the function itself.
  6. Add retry logic in the caller, because the platform does not retry failed runs.
  7. Push results out to a database, file mount, or webhook, because a task has no HTTP endpoint for callers to poll.

 

Frequently Asked Questions

Are Upsun task containers serverless?

They follow a similar model: triggered, run, exit, with per-second billing for run time. They run inside an Upsun environment next to an application, not on a shared function fleet, and a project needs at least one application to run them.

What is the maximum run time of an Upsun task container?

24 hours. The run.timeout setting defaults to 3,600 seconds and accepts up to 86,400 seconds.

Can an Upsun task container replace AWS Lambda?

For jobs that work against an application's own data, such as imports, reports, or agent runs, a task can take over the work. For high fan-out event handling, HTTP endpoints, or native AWS event sources, Lambda fits better.

Can a cron job start an Upsun task container?

Not directly. An Upsun cron job can call the tasks API, which is the pattern in Upsun's cron tutorial.

Do Upsun task containers retry failed runs?

No. Each run is recorded as an activity with its final status, and the caller decides whether to run the task again.

Can an Upsun task container serve HTTP requests?

No. Tasks are not routable. A task sends its results to a database, a file mount, or an external endpoint.

How do serverless functions handle jobs longer than their limit?

Teams split the work into steps, use a workflow product such as Lambda Durable Functions or Azure Durable Functions, or move the job to a container product with a longer limit, such as Lambda MicroVMs or Cloud Run jobs.

Stay updated

Subscribe to our monthly newsletter for the latest updates and news.

Deploy possibility.
Try Upsun for free.

Build with DispatchDeploy on Cloud