A head-to-head comparison of Vercel and Google Cloud Run for an API with a database and long-running work: functions against containers, request and job limits, databases, schedules, pricing and how to run the backend on Cloud Run without wiring it by hand.

Vercel runs backend code as functions next to a frontend, with routing, previews and a CDN handled by the platform. Google Cloud Run runs any container, scales it with traffic and can take it to zero, and leaves the database, queue and scheduler to other products.
They meet on APIs, where the question is whether the API belongs to the frontend project or is a service of its own.
Vercel figures are from its pricing page, function limits and Schedules docs, and Cloud Run figures from the quotas page and pricing page, checked November 30, 2026.
A Vercel function exists for the length of a request, with a default limit of 300 seconds and longer durations that can be configured. That suits route handlers, server rendering and short API calls, and it means an import, a report or a call to a slow upstream has to be split into steps or moved elsewhere.
Cloud Run keeps a container alive while it has traffic, allows a request to run for up to 60 minutes and handles up to 80 concurrent requests per instance by default, with a ceiling of 1,000. A Cloud Run job runs a container to completion for up to 168 hours with up to 10,000 tasks, which is the right shape for batch work that would otherwise sit inside a request.
Vercel does not run databases, so Postgres and Redis come from partners in the Vercel Marketplace and are attached to the project, and functions that scale out open many short-lived connections, so pooled connection strings matter.
Cloud Run does not include a database either, and the usual pairing is Cloud SQL for Postgres, connected to the service through the Cloud SQL connector or a private IP, with its own instance sizing and maintenance windows. Scheduling is Cloud Scheduler calling a service URL or a job with a service account that has permission to invoke it.
Pick Vercel when the API is a handful of route handlers inside a Next.js project and previews on every push matter more than backend limits. Pick Cloud Run when the backend is its own service that needs longer requests, background work, a private database and the ability to run in a project your company owns.
Encore is a backend framework with built-in infrastructure, and on Google Cloud it deploys each service to Cloud Run with a Cloud SQL database and Pub/Sub topics created from the declarations in code, as the GCP infrastructure docs describe. It also provisions the surrounding service accounts, the database connection and the scheduler from those declarations, while a Vercel frontend keeps deploying from git and calls the backend through a typed client from encore gen client.

Run in your terminal to get started locally.
A catalog import is the kind of work that outgrows a function. This service stages rows, then a subscriber copies them into the catalog in batches of 1,000 and records a cursor after each batch, so a retry or a second delivery continues where the first stopped instead of starting over:
// catalogsync/sync.go
package catalogsync
import (
"context"
"errors"
"time"
"encore.dev/beta/errs"
"encore.dev/cron"
"encore.dev/pubsub"
"encore.dev/storage/sqldb"
)
var db = sqldb.NewDatabase("catalogsync", sqldb.DatabaseConfig{Migrations: "./migrations"})
type SyncRequested struct {
ID int64 `json:"id"`
}
var requested = pubsub.NewTopic[*SyncRequested]("catalog-sync-requested", pubsub.TopicConfig{
DeliveryGuarantee: pubsub.AtLeastOnce,
})
type StartResponse struct {
ID int64 `json:"id"`
}
// Start records a run and queues it, returning straight away.
//
//encore:api public method=POST path=/syncs
func Start(ctx context.Context) (*StartResponse, error) {
var id int64
if err := db.QueryRow(ctx, `INSERT INTO sync_runs DEFAULT VALUES RETURNING id`).Scan(&id); err != nil {
return nil, err
}
if _, err := requested.Publish(ctx, &SyncRequested{ID: id}); err != nil {
return nil, err
}
return &StartResponse{ID: id}, nil
}
type Run struct {
ID int64 `json:"id"`
Status string `json:"status"`
Processed int64 `json:"processed"`
}
//encore:api public method=GET path=/syncs/:id
func Get(ctx context.Context, id int64) (*Run, error) {
var r Run
err := db.QueryRow(ctx, `SELECT id, status, processed FROM sync_runs WHERE id = $1`, id).
Scan(&r.ID, &r.Status, &r.Processed)
if errors.Is(err, sqldb.ErrNoRows) {
return nil, &errs.Error{Code: errs.NotFound, Message: "sync run not found"}
}
if err != nil {
return nil, err
}
return &r, nil
}
const batchSize = 1000
// step copies one batch and reports whether the run is finished.
func step(ctx context.Context, id int64) (bool, error) {
tx, err := db.Begin(ctx)
if err != nil {
return false, err
}
defer tx.Rollback()
var cursor int64
var status string
err = tx.QueryRow(ctx, `SELECT cursor, status FROM sync_runs WHERE id = $1 FOR UPDATE`, id).
Scan(&cursor, &status)
if err != nil {
return false, err
}
if status == "done" {
return true, nil
}
var n, last int64
err = tx.QueryRow(ctx, `
WITH batch AS (
SELECT id, sku, name, cents FROM incoming
WHERE id > $1 ORDER BY id LIMIT $2
), up AS (
INSERT INTO catalog (sku, name, cents)
SELECT sku, name, cents FROM batch
ON CONFLICT (sku) DO UPDATE
SET name = EXCLUDED.name, cents = EXCLUDED.cents, updated_at = now()
RETURNING 1
)
SELECT count(*), COALESCE(max(id), $1) FROM batch`, cursor, batchSize).Scan(&n, &last)
if err != nil {
return false, err
}
_, err = tx.Exec(ctx, `
UPDATE sync_runs
SET cursor = $2, processed = processed + $3,
status = CASE WHEN $3 = 0 THEN 'done' ELSE 'running' END
WHERE id = $1`, id, last, n)
if err != nil {
return false, err
}
return n == 0, tx.Commit()
}
var _ = pubsub.NewSubscription(requested, "run-sync", pubsub.SubscriptionConfig[*SyncRequested]{
Handler: func(ctx context.Context, m *SyncRequested) error {
for {
done, err := step(ctx, m.ID)
if err != nil {
return err
}
if done {
return nil
}
}
},
RetryPolicy: &pubsub.RetryPolicy{MinBackoff: 10 * time.Second, MaxBackoff: 5 * time.Minute, MaxRetries: 5},
})
//encore:api private
func Nightly(ctx context.Context) error {
_, err := Start(ctx)
return err
}
var _ = cron.NewJob("nightly-catalog-sync", cron.JobConfig{
Title: "Start the nightly catalog sync",
Schedule: "0 2 * * *",
Endpoint: Nightly,
})
-- catalogsync/migrations/1_create_tables.up.sql
CREATE TABLE incoming (
id BIGSERIAL PRIMARY KEY,
sku TEXT NOT NULL,
name TEXT NOT NULL,
cents BIGINT NOT NULL
);
CREATE TABLE catalog (
sku TEXT PRIMARY KEY,
name TEXT NOT NULL,
cents BIGINT NOT NULL,
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE TABLE sync_runs (
id BIGSERIAL PRIMARY KEY,
status TEXT NOT NULL DEFAULT 'queued',
cursor BIGINT NOT NULL DEFAULT 0,
processed BIGINT NOT NULL DEFAULT 0,
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
encore run starts Postgres locally, applies the migration and runs the subscriber in process. Inserting rows into incoming and calling POST /syncs is how you exercise that path: the in-process subscriber copies rows in batches and advances the cursor after each batch. Cron jobs do not run locally, so the nightly schedule is tested by calling the endpoint it points at. The Pub/Sub docs cover retries and the dead-letter queue, the database docs cover transactions and migrations, and the cron docs cover schedules, which the Encore platform manages.
To deploy, follow Connect your cloud account for a Google Cloud project and push, and the Cloud Run services, Cloud SQL database and Pub/Sub topic appear in that project. When an AI coding agent adds a second import source, the new table, the batch query and the handler are one change that it runs locally first.
Best fit: Teams that keep a Vercel frontend and want the API on Cloud Run with its database, topics and schedules declared next to the code instead of assembled in the console.
Choose Vercel for an API that belongs to a Next.js project and finishes within function limits, and Cloud Run for a backend with long requests, batch work and a database of its own. Encore covers the second case by creating the Cloud Run, Cloud SQL and Pub/Sub resources from the code in your own project.
Cloud Run is the better fit for an API that is not a frontend companion, since it runs any container, allows requests of up to 60 minutes and runs batch work as Cloud Run jobs for up to 7 days. Vercel is the better fit when the API sits next to a Next.js app and finishes inside function limits.
Vercel functions default to 300 seconds, and longer durations are configurable, while a Cloud Run request can last up to 60 minutes. Cloud Run jobs run tasks for up to 168 hours.
No. Vercel does not run databases itself and connects partner databases from its Marketplace to a project. Cloud Run pairs with Cloud SQL, which is a separate Google Cloud service with its own pricing and connection setup.
Build the backend with Encore, declaring its database, topics and cron jobs in code, connect your Google Cloud project and push. Encore deploys the services to Cloud Run with Cloud SQL and Pub/Sub, and a Vercel frontend can keep calling it through a 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.