Where to Host a Next.js App With Postgres and a Background Worker

Cover for Pristren’s guide to hosting Next.js with Postgres and background workers
TL;DR

Your Next.js app works until an export times out or runs twice. Compare four hosting setups for Postgres and background jobs, then test what happens when a worker restarts.

Imagine clicking Export CSV in your Next.js app. With a dozen test records, the download is instant. A customer tries it with a year's worth of orders, closes the browser when it takes too long, and clicks Export again. Later there are two jobs, one half-written file, and no obvious way to tell which request produced it. Moving to a bigger web server might buy time. The more durable fix is to record the request, return a job ID, and let another process handle the export.

Start with Render if you want a separately priced web service, a continuous worker, and managed Postgres. Start with Railway if you want the services together in one project and are comfortable measuring resource usage. Consider Sevalla if you want managed Postgres and a separately sized worker process. If your app already runs well on Vercel, keep it there while you evaluate a queue-triggered function, a Vercel Daemon, or an external worker. The right choice depends on what the job does after a timeout, a deployment, or a retry.

This guide compares provider documentation and published pricing checked December 2, 2026. The example below is a proposed workload you can reproduce. The cost figures are illustrations based on published rates. Deployment time, throughput, recovery time, and actual invoices require testing on your selected plans.

Compare the full stack at a glance

Click any column to sort
4 rows
RenderNode.js web serviceContinuous background worker serviceRender PostgresBudget for each instance, database storage, and any queue service. Check the workspace tier for previews and recovery retention.
RailwayApplication serviceSeparate service running your worker commandPostgreSQL service from a template, with optional recovery and managed high-availability configurationEstimate CPU, memory, storage, and egress across the web app, worker, and database. Check whether services may sleep.
SevallaWeb process deployed from Git or a containerBackground worker process with its own resourcesManaged PostgreSQLPrice both process sizes and database resources. Check build, transfer, and storage charges for the chosen setup.
VercelNext.js deploymentQueue-triggered functions for bounded jobs, a Daemon for a continuous process where supported, or an external workerPostgres through a Marketplace provider or an existing databaseVerify beta eligibility, runtime and region limits, and which products bill separately.

Render's Next.js documentation · Railway's full-stack deployment guide · Sevalla's process and deployment guide · Vercel Queues · Vercel Daemons limits · Postgres on Vercel

If you're also weighing whether to maintain your own server, start with Pristren’s comparison of Coolify, Fly.io, and Render. The decision here assumes you need at least one persistent data store and a separate way to execute jobs.

Decide what must keep running

Start with the export itself. If it finishes quickly and predictably and the user needs the result before proceeding, doing the work in the request can be reasonable. If it should run at 2 a.m. and it has a predictable upper bound, a scheduled job may be enough. If work comes from user requests and should survive a closed tab or a deploy, use a persistent job record and an execution method that can retry. That could be a continuous process or a queue that invokes a function as needed.

A continuous worker makes sense when you already use a library that polls a queue, need a long-lived connection, or want a single process to regulate how fast it consumes jobs. A queue-triggered function can fit jobs that reliably complete within the runtime limits and only arrive occasionally. A workflow engine is worth considering when the job needs multiple durable steps, long waits, or coordination with another service. Check the failure and timeout behavior for the option you pick. The word “background” by itself tells you very little about either. Render workers · Vercel Queues · Vercel Functions limits

To compare the hosts, use one CSV export scoped to a test organization. The web app validates permissions and writes a job with a unique request key to Postgres. It returns a job ID, and the UI shows progress by reading the status. The worker claims the job, creates a private file, and records completion. Keep the file in object storage if downloads need to survive redeploys or be served by a different instance. Use synthetic records for the test so you can run the same export on every host.

For a small test, the job table can also act as the queue. Use a mature Postgres-backed queue library or a design with an atomic claim, an expiring lease, and a retry limit. That keeps the initial comparison to three pieces: app, worker, and database. If your application already needs Redis or another dedicated broker, include it in every applicable estimate. For a queue-triggered deployment, account for how job creation and message publication stay coordinated. A transactional outbox is one way to avoid a job being saved without a corresponding message when a publish call fails.

If the web service and worker share a database, count connections from both processes when sizing the pool. Pristren’s guide to database connection pooling in Next.js · Next.js self-hosting guide

Render suits a conventional app-and-worker deployment

Render offers a public web service for Next.js and a separate background worker that runs continuously. The worker usually consumes jobs from a queue and doesn't receive incoming requests. That lets you deploy the web server and worker with different commands and resource sizes. Put Postgres in the same region and use its internal connection URL where available. If the worker can access the same job table, you can compare the three-service setup before adding a dedicated broker. Render's Next.js hosting docs · Background workers · Render Postgres

For a one-person prototype, the published rates give a useful starting calculation. A $7 web instance and a $7 worker plus a $6 Postgres compute tier give $20 per month in compute before database storage and applicable usage charges. This uses a Hobby workspace and assumes the smallest selected instances fit. If you need the $25 Pro workspace, add that fee to the selected resources. These numbers show how the bill is assembled and provide no evidence that a 512 MB worker can handle your largest export. Render pricing · Compute plan sizes

Check restore terms early. Render documents point-in-time recovery for paid Postgres, with a three-day window on Hobby and seven days on Pro or higher. Its recovery process creates a new database instance, so practice validating that instance and switching connections in a test environment. Because the worker and web app both write to Postgres, your restore plan needs to account for both. Render's recovery documentation

Railway puts multiple services in one project

Railway's official guide deploys a Next.js service, a worker, Postgres, and a Redis-backed queue together. For this example, set up the web service and worker as separate services. The worker can start with its own command and use an internal database connection. Give it only the variables it needs. If you use an independent preview environment, verify that both the web app and worker connect to preview data. One misplaced connection string can send preview exports into the production queue. Railway's full-stack guide · Private networking

Railway's $5 Hobby subscription includes $5 toward eligible usage. Here's how to read that number. If the project used $12 of eligible Railway resources in a month, the subscription and usage would total $12 under that credit model, before extras outside the example. The $12 is a hypothetical usage figure. An always-on worker and a running database can contribute to the bill on a day when nobody requests an export. Estimate the normal floor and measure again after a busier day. If you enable sleeping, check whether the worker's queue and database connections keep it active or how it wakes up. Railway pricing plans and usage · Serverless service behavior

The default PostgreSQL template provisions a single node. Railway documents a path to managed high availability, and you should explicitly check and configure your backups or point-in-time recovery. Budget these choices for the database you intend to operate, especially if losing the primary would block both the app and the worker. Railway PostgreSQL · Point-in-time recovery

Sevalla is an option when you want to size processes separately

Sevalla documents deploying Next.js as a web process and running background workers as another process type. Its managed database offering includes PostgreSQL and advertises automatic daily backups. The configuration to evaluate is one web process, one worker process, and a database on a supported internal network. Confirm the process start command and keep web and worker logs easy to tell apart so you can trace a job from request to completion. Sevalla Next.js tutorial · Process types and build strategy · Database hosting

Sevalla lists entry prices from $5 per month for application hosting and $5 per month for database hosting. Those give you two inputs to a quote. The worker also needs a running configuration, so $10 is an incomplete estimate for this workload. Price the web and worker process sizes, database, and any associated storage, builds, or transfer. Then check the backup method against your recovery requirement. Daily restore points can be fine for a prototype and too far apart for customer data that changes all day. Sevalla application pricing · Database pricing

Keep Vercel if moving the web app brings little benefit

If your team relies on Vercel's Next.js previews and the web app already runs well there, first price moving just the worker. A queue-triggered function suits an export that can finish within its time and memory limits. Vercel Queues is documented as beta and uses at-least-once delivery, which means your handler must tolerate seeing the same message more than once. For a process that polls continuously, Vercel lists Daemons in public beta. Check plan availability, supported regions, and runtime constraints before basing a production design on it. You can also run the worker on another host and keep Vercel for requests and previews. Vercel Queues · Daemons announcement · Daemons limits

Vercel lists Pro at $20 per month with $20 of included usage credit. For a full-stack estimate, count plan fees and usage, the actual Postgres provider, plus queues or workers and cross-provider transfer where applicable. Vercel's Postgres documentation directs new projects to Marketplace database integrations, so check the provider's pricing and connection guidance as well. For a hybrid setup, check where the database lives and how both the app and worker reach it. The split can be straightforward if the web app only records jobs and reads status, and more involved if it makes many latency-sensitive database calls. Vercel pricing · Postgres integrations · Spend Management

Compare the bill before you migrate

Write down your inputs before looking at totals. A useful first estimate might assume one web instance, one worker, one small database, and 730 running hours for the month. Add a realistic count of jobs, expected time and peak memory per job, retained file size, transfers, and the number of developers who need workspace access. Use the same inputs across hosts where the architectures allow it. For an event-driven setup, record execution time and queue operations where a continuous-worker setup records running hours and resource usage.

Separate the baseline from the busy-month case. In the baseline, ask what you pay when nobody clicks Export. In the busy case, ask what happens when a customer starts ten exports, retries spike, or a month of files accumulates. Check how each plan handles an exceeded budget, including whether charges continue, alerts fire, or production is paused. Decide whether a stopped service would be acceptable for this application. Prices and included usage are only useful once you know which resources your deployment requires.

When you run a pilot, keep four things with the results: the plan and region, the exact workload, your itemized usage, and what the observed period leaves out. An hour of compute can help you estimate your baseline. Budget separately for recovery drills, storage growth, preview environments, and occasional larger jobs. If an internal call becomes cross-provider traffic after a migration, add that line to the new setup's estimate.

Run a failure test before switching traffic

Use a non-production deployment and a fixed synthetic dataset. Capture the time from a click to job acceptance and from acceptance to file availability so slow processing is visible separately from a slow web request. Keep the same Next.js build and worker logic across continuous-worker hosts. Where the execution model changes, describe what you changed, such as swapping a polling consumer for a queue-triggered function.

  1. Submit the same export request twice. Reuse the request key and check that you get one logical job. Use an organization-scoped key so one tenant cannot collide with another tenant's request.
  2. Restart the worker during an export. Confirm that another attempt can claim the job after the lease expires or the queue makes it available again. Check that duplicate attempts produce one final result and that the completed file can be opened.
  3. Deploy a web change while jobs are running. Check whether jobs already in progress finish. If the release changes the database schema, make the first migration compatible with the previous worker version and check the deploy order.
  4. Restore a backup into a clean database. Point a test copy of the app and worker at the restored database. Compare row counts and inspect job states. Restore the database before you test whether its referenced files are still available. A database snapshot alone cannot bring back files that were stored elsewhere.
  5. Try opening a file from a different test account. Check that the download path enforces ownership and that any signed link expires as intended. Verify status and download endpoints independently.
  6. Record job completion and queue age. A healthy home page can coexist with exports that have been waiting for an hour. Carry the same job ID through request and worker logs, and check that a failed or stalled job can be found without searching by timestamp alone.

A useful launch threshold is concrete enough to check. Start with “an interrupted export is picked up again, only one final file is presented, and support can find its status by job ID.” Then decide how much delay is acceptable for the product. If one platform meets that bar and the team already understands its deploy and billing model, that's a strong reason to choose it. A lower entry price is useful only if the recovery, preview, and support setup still fits.

Frequently Asked Questions

Can Next.js run a background worker by itself?

A Next.js application can accept jobs and expose their status. For work that must survive timeouts or app restarts, persist the jobs and use a worker, queue consumer, or workflow that supports your retry needs. On Node.js hosting, the worker can share the repository with the web app and run as a separate process.

Do I need Redis for background jobs in a Next.js app?

A Postgres-backed queue can be enough for a modest workload if it handles durable claims, retries, and recovery from a stopped worker. Use a separate broker when your chosen worker library requires it or your measured load and operational requirements justify it. Price the broker, persistence settings, and recovery along with the worker.

Should I move my whole app off Vercel to add a worker?

Try the smallest change that meets your requirements. If the web app and previews already suit the team, evaluate keeping Next.js on Vercel and adding a queue-triggered function or an external worker. Compare a full migration if you need common private networking, fewer deployment configurations, or a service model that better fits both parts of the app.

Can web and worker processes share the same Postgres database?

Yes. Give both services a compatible connection configuration and account for their combined connection use. Keep database credentials server-side, size pools for the number of web and worker instances, and verify that a preview worker uses its own environment's database.

#next.js#postgresql#background-jobs#developer-hosting

One AI engineering post, weekly

LLM benchmarks, prompt techniques, and token-cost breakdowns, delivered to your inbox.

What should we test or explain next?

Comments

Have a question or something to add? Sign in to join the discussion.

Mohammad Mohiuddin — SEO & Content Specialist at Pristren

Mohammad Mohiuddin

SEO & Content Specialist

Mohammad Mohiuddin, also known as Mohi Qudraty, works on technical SEO, web optimization, and content at Pristren. His development focus is full-stack web engineering with React, TypeScript, Node.js, and PostgreSQL.