A head-to-head comparison of Vercel and Cloudflare Workers for apps with a backend: runtime and CPU limits, Next.js support, databases and storage, background work, pricing and where a growing backend should run.

Vercel deploys a Next.js app from git with preview URLs and functions for the server-side parts, and it is the default home for frontend-led products. Cloudflare runs code as Workers in V8 isolates across its network, with D1, R2, Queues and Durable Objects next to them on one bill.
For a site with a few API routes either one is plenty. The gap shows up in the backend, where CPU limits, database location and background jobs decide how much of the app each platform can actually hold.
Cloudflare figures are from the Workers limits and pricing docs, and Vercel figures from its duration docs and pricing page, all checked November 25, 2026.
Vercel runs functions on Fluid compute, where one instance can serve several requests at once, in the regions you choose, with Node.js, Bun and Python runtimes and a default of 300 seconds per invocation that Pro teams can raise to 800, plus up to 30 minutes as a beta. Most Node.js libraries work unchanged, including Postgres drivers that hold a TCP connection.
A Worker is an isolate with Web APIs and a Node.js compatibility layer, and it starts in milliseconds wherever the request lands. Cloudflare limits CPU time rather than wall time, so a Worker can wait on a slow upstream API without using its budget, but parsing a large payload or rendering a heavy page eats into the 30-second default, and the 128 MB memory limit applies to the whole isolate. Libraries that depend on native modules or the full Node.js runtime may not run without changes, which is why Cloudflare added Containers for workloads that need them.
Vercel builds Next.js, and new features such as Partial Prerendering and caching changes land there first. Cloudflare's Next.js guide now recommends vinext, a reimplementation of the Next.js API on Vite that deploys to Workers, with OpenNext as the alternative, and npx vinext check reports which features an app uses that are not supported yet.
For Astro, SvelteKit, React Router and static sites, both platforms are mature, and the choice comes down to price and to where the data lives.
Cloudflare has the more complete set of building blocks: D1 is SQLite capped at 10 GB per database and designed for many small databases such as one per tenant, Hyperdrive pools connections to an existing Postgres database, R2 stores objects with no egress charges, and Durable Objects give you strongly consistent state per key. Vercel does not run its own database and provisions Postgres from Marketplace providers such as Neon, with Vercel Blob for files.
A Worker running near the user still has to reach one primary database, so an app with a single Postgres in Frankfurt gains little from executing in Sydney unless reads are cached or the data is split into D1 or Durable Objects.
Cloudflare Queues deliver messages to a consumer Worker with retries and dead-letter queues, Workflows run durable multi-step jobs, and Cron Triggers run on a schedule with up to 15 minutes of CPU time for intervals of an hour or more. Vercel offers Workflows for durable steps, Queues as a beta, and cron through its scheduling features.
Neither platform keeps an ordinary process running, so a consumer that polls continuously, a job that needs a gigabyte of memory or a service that holds connections to several internal systems has to go somewhere else.
Pick Vercel for Next.js-first products, teams that want the newest framework features with no adapter, and API routes that need Node.js libraries and several minutes per request. Pick Cloudflare when request volume or bandwidth makes price the deciding factor, when edge execution, D1 per tenant or Durable Objects fit the design, or when R2's zero egress matters for serving files. Pick neither for a backend that has to run as long-lived services or inside your own AWS or GCP account, since Vercel's Bring Your Own Cloud covers functions on Enterprise plans only.
Encore is a backend framework with built-in infrastructure, and with either frontend host it takes over the part that no longer fits in functions or isolates: services that run continuously in your own AWS or GCP account, with Postgres, Pub/Sub and buckets declared in the code. Encore provisions RDS, SNS with SQS and S3 on AWS, or Cloud SQL, Pub/Sub and Cloud Storage on GCP, per the infrastructure docs, and an environment can also use Cloudflare R2 as its object storage if you want to keep files on Cloudflare.

Run in your terminal to get started locally.
A CSV import is a typical job that outgrows a request CPU budget. The browser uploads the file straight to the bucket through a signed URL, and a subscriber processes it in a service with no per-request CPU cap:
// imports/imports.go
package imports
import (
"context"
"crypto/sha256"
"encoding/csv"
"encoding/hex"
"errors"
"fmt"
"io"
"strconv"
"strings"
"time"
"encore.dev/beta/auth"
"encore.dev/beta/errs"
"encore.dev/pubsub"
"encore.dev/storage/objects"
"encore.dev/storage/sqldb"
)
var db = sqldb.NewDatabase("imports", sqldb.DatabaseConfig{Migrations: "./migrations"})
var uploads = objects.NewBucket("import-uploads", objects.BucketConfig{})
type ImportRequested struct {
ImportID int64 `json:"import_id"`
OwnerID string `json:"owner_id"`
}
var importRequested = pubsub.NewTopic[*ImportRequested]("import-requested", pubsub.TopicConfig{
DeliveryGuarantee: pubsub.AtLeastOnce,
})
type CreateResponse struct {
ImportID int64 `json:"import_id"`
UploadURL string `json:"upload_url"`
}
const maxImportBytes = 10 << 20 // 10 MB
func objectName(owner string, id int64) string {
return fmt.Sprintf("imports/%s/%d.csv", owner, id)
}
func csvContentType(t string) bool {
t = strings.ToLower(strings.TrimSpace(strings.Split(t, ";")[0]))
return t == "" || t == "text/csv" || t == "application/csv" || t == "text/plain" || t == "application/octet-stream"
}
func sessionHash(token string) string {
sum := sha256.Sum256([]byte(token))
return hex.EncodeToString(sum[:])
}
//encore:authhandler
func AuthHandler(ctx context.Context, token string) (auth.UID, error) {
if token == "" {
return "", &errs.Error{Code: errs.Unauthenticated, Message: "missing auth token"}
}
var ownerID string
err := db.QueryRow(ctx, `
SELECT user_id FROM sessions
WHERE token_hash = $1 AND expires_at > now() AND revoked_at IS NULL`, sessionHash(token)).
Scan(&ownerID)
if errors.Is(err, sqldb.ErrNoRows) {
return "", &errs.Error{Code: errs.Unauthenticated, Message: "unknown, expired or revoked session"}
}
if err != nil {
return "", err
}
return auth.UID(ownerID), nil
}
// CreateImport returns a signed URL that the browser uploads the CSV to directly.
// Only the signed-in caller can create an import, and the object key is bound to them.
//
//encore:api auth method=POST path=/imports
func CreateImport(ctx context.Context) (*CreateResponse, error) {
uid, _ := auth.UserID()
owner := string(uid)
var n int
if err := db.QueryRow(ctx, `
SELECT COUNT(*) FROM imports
WHERE owner_id = $1 AND created_at > now() - interval '1 hour'`, owner).Scan(&n); err != nil {
return nil, err
}
if n >= 20 {
return nil, &errs.Error{Code: errs.ResourceExhausted, Message: "import creation rate limit exceeded"}
}
var id int64
if err := db.QueryRow(ctx, `
INSERT INTO imports (status, owner_id) VALUES ('awaiting_upload', $1) RETURNING id`, owner).Scan(&id); err != nil {
return nil, err
}
u, err := uploads.SignedUploadURL(ctx, objectName(owner, id), objects.WithTTL(15*time.Minute))
if err != nil {
return nil, err
}
return &CreateResponse{ImportID: id, UploadURL: u.URL}, nil
}
// StartImport is called by the frontend after the upload has finished.
//
//encore:api auth method=POST path=/imports/:id/start
func StartImport(ctx context.Context, id int64) error {
uid, _ := auth.UserID()
owner := string(uid)
attrs, err := uploads.Attrs(ctx, objectName(owner, id))
if errors.Is(err, objects.ErrObjectNotFound) {
return &errs.Error{Code: errs.FailedPrecondition, Message: "upload not found"}
}
if err != nil {
return err
}
if attrs.Size > maxImportBytes {
return &errs.Error{Code: errs.InvalidArgument, Message: "CSV must be 10 MB or smaller"}
}
if !csvContentType(attrs.ContentType) {
return &errs.Error{Code: errs.InvalidArgument, Message: "upload must be a CSV file"}
}
res, err := db.Exec(ctx, `
UPDATE imports SET status = 'queued'
WHERE id = $1 AND owner_id = $2 AND status = 'awaiting_upload'`, id, owner)
if err != nil {
return err
}
if res.RowsAffected() == 0 {
return &errs.Error{Code: errs.FailedPrecondition, Message: "import is not awaiting upload"}
}
_, err = importRequested.Publish(ctx, &ImportRequested{ImportID: id, OwnerID: owner})
return err
}
var _ = pubsub.NewSubscription(importRequested, "process-import", pubsub.SubscriptionConfig[*ImportRequested]{
Handler: processImport,
RetryPolicy: &pubsub.RetryPolicy{MinBackoff: 10 * time.Second, MaxBackoff: 5 * time.Minute, MaxRetries: 5},
})
func processImport(ctx context.Context, ev *ImportRequested) error {
var status string
if err := db.QueryRow(ctx, `SELECT status FROM imports WHERE id = $1`, ev.ImportID).Scan(&status); err != nil {
return err
}
if status == "done" {
return nil // redelivered message for a finished import
}
r := uploads.Download(ctx, objectName(ev.OwnerID, ev.ImportID))
defer r.Close()
rows := csv.NewReader(r)
if _, err := rows.Read(); err != nil {
return fmt.Errorf("read header: %w", err)
}
tx, err := db.Begin(ctx)
if err != nil {
return err
}
defer tx.Rollback() // no-op after Commit
for {
rec, err := rows.Read()
if errors.Is(err, io.EOF) {
break
}
if err != nil {
return err
}
qty, err := strconv.Atoi(rec[1])
if err != nil {
return fmt.Errorf("bad quantity for %s: %w", rec[0], err)
}
// Upserting by SKU makes a retried import safe to run again.
if _, err := tx.Exec(ctx, `
INSERT INTO stock (sku, quantity, import_id) VALUES ($1, $2, $3)
ON CONFLICT (sku) DO UPDATE SET quantity = EXCLUDED.quantity, import_id = EXCLUDED.import_id`,
rec[0], qty, ev.ImportID); err != nil {
return err
}
}
if _, err := tx.Exec(ctx, `UPDATE imports SET status = 'done' WHERE id = $1`, ev.ImportID); err != nil {
return err
}
return tx.Commit()
}
-- imports/migrations/1_create_imports.up.sql
CREATE TABLE sessions (
token_hash TEXT PRIMARY KEY,
user_id TEXT NOT NULL,
expires_at TIMESTAMPTZ NOT NULL,
revoked_at TIMESTAMPTZ
);
CREATE TABLE imports (
id BIGSERIAL PRIMARY KEY,
owner_id TEXT NOT NULL,
status TEXT NOT NULL CHECK (status IN ('awaiting_upload', 'queued', 'done')),
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE TABLE stock (
sku TEXT PRIMARY KEY,
quantity INTEGER NOT NULL CHECK (quantity >= 0),
import_id BIGINT NOT NULL REFERENCES imports (id)
);
encore run starts Postgres, the topic and the bucket locally, so the upload, the queued job and the import can be tested on a laptop and followed in the local traces. The object storage docs cover signed URLs, and the Pub/Sub docs cover retries and the dead-letter queue a failing import lands in.
To deploy, connect your AWS or GCP account as described in Connect your cloud account and push, and point the Vercel or Cloudflare frontend at the backend URL. If an AI coding agent later adds a second import type, the table, the topic and the handler it needs go in one diff that it can run locally before review.
Best fit: Teams that want to keep their frontend on Vercel or Cloudflare and run the backend, its database and its jobs as services in their own AWS or GCP account.
Choose Vercel for Next.js-first products and server code that needs the full Node.js runtime, and Cloudflare for high traffic at low cost, edge execution and storage without egress fees. When the backend grows past what functions or isolates hold comfortably, keep the frontend where it is and move the backend to long-running services in your own cloud account.
It usually is once request volumes are high: Workers Paid starts at $5 a month for the account with 10 million requests and 30 million CPU milliseconds included, and Cloudflare charges nothing for egress bandwidth. Vercel Pro is $20 a month with $20 of usage credit included, and bandwidth and function usage beyond that credit are billed on top.
Yes. Cloudflare recommends vinext, which reimplements the Next.js API on Vite and deploys to Workers, and OpenNext is the other supported path. Vercel still supports new Next.js features first, so apps that depend on the newest App Router or caching behavior carry less risk there.
Workers Free allows 10 ms of CPU time per request. Workers Paid defaults to 30 seconds and can be raised to 5 minutes, and time spent waiting on fetch calls or database queries does not count, while memory is capped at 128 MB per isolate.
Build the backend with Encore, declaring its database, queues and buckets in code, and deploy it to your own AWS or GCP account as long-running services. The frontend keeps deploying to Vercel or Cloudflare and calls the backend through a generated, typed client.
Deploy to your cloud on AWS and Google Cloud
without managing infrastructure
Encore lets developers and agents define application infrastructure directly in code, then automatically provisions it from local development to production in your AWS or GCP account.