r/nextjs • • 17d ago

Vercel alternatives once a Next.js app needs a database and background jobs, what did you move to?

Side project started as a pure Next.js frontend on Vercel. Then it grew a Postgres db through the marketplace, file uploads and a queue worker that turns big CSV uploads into reports, and the worker is where it stopped fitting. The big ones run about 40 minutes, which is past the 30 minute beta on functions, and they don't split into Workflows steps. Daemons would probably run it but they're in public beta.

I moved it onto the box I keep for other projects and it fell over twice while I was asleep, so that's not the answer either. It's only a few users so far and I'd like to make this move once, with the app and the worker in one place. Been reading up on Railway, ample.computer and Render. For anyone who took a Next.js app with background jobs off Vercel, what did you move to?

8 Upvotes

37 comments sorted by

5

u/Guanakita-Istuk 14d ago

npx extraorbital is a great complement to Vercel IMHO. Gives you serverless DBs like Neon (PostgreSQL) and access to Modal sandboxes for long background jobs. Everything on the same account. You can also run jobs up to 9min long on vercel functions already.

4

u/Available_Green_7868 17d ago

Whatever host you pick, I'd run the worker as its own long-running service instead of a function, because a 40 minute job will keep fighting serverless limits anywhere. Railway and Render both let you put the Next.js app and a background worker in one project on the same Postgres, so it still lives in one place.

The bigger fix for the overnight crashes is making jobs survive a restart. Keep a jobs table with a status and heartbeat, have the worker claim rows with SELECT ... FOR UPDATE SKIP LOCKED, and save progress in chunks so a restarted job picks up where it stopped instead of starting over. pg-boss or graphile-worker give you this on top of Postgres, so you don't need Redis just for the queue.

1

u/Fun_Improvement7704 16d ago

making the jobs resumable is definitely the part people skip until it bites them overnight

3

u/RequirementGuide 17d ago

I've hit this before and the move that worked best for me was the smallest one. I kept the Next.js app on Vercel and moved only the worker to a Render background worker sharing the same Postgres. That kept the app and the job in one place without me having to rebuild the whole deployment.

The other thing that saved me was a dead simple healthcheck on the worker plus an uptime alert to my phone. My box used to fall over at night too and I only found out from users. Now if the worker stops I know in a few minutes instead of the next morning. If you go the VPS route, make sure the worker restarts itself automatically, otherwise you are just moving the same 3am problem to a different box.

2

u/Unav4ila8le 17d ago

Any VPS with Dokploy works 10x better than Vercel

1

u/sleeskeaer 16d ago

yeah self-hosting on a dedicated box makes way more sense once you have long-running workers like that

1

u/madfcat 16d ago

have you used coolify? how is it compared to Dokploy?

2

u/Unav4ila8le 16d ago

i just went with Dokploy since the beginning, never tried coolify yet

2

u/MeasurementGreat5273 16d ago

Haven't run either one, sorry

2

u/Azarro 17d ago

Vercel's screwed me over on side stuff where I get millions of visitors every month - like the pricing changes over the last 2 years have been pretty crazy.

For a new project recently that's been picking up (won't ever hit millions but maybe 10-50k per month eventually), I just put my nextjs app on one of my droplets and set up my redis/postgres/nextjs APIs and other infra there and I've been fine.

1

u/TechnicolourSleep 17d ago

I’ve had good luck with Cloudflare workers, but nothing that needed to run super long, so YMMV. Might be worth checking out!

1

u/karmatics29 17d ago

One thing I’d check before choosing is where uploads and generated reports live: don’t leave them on the app or worker filesystem, since deploys and instance replacement can discard it. Put files in object storage and keep their keys plus job state and progress in Postgres; have the Next.js route enqueue the key and return a job ID, while a separate worker processes and checkpoints chunks. That keeps the app responsive and lets you restart or scale the worker without tying jobs to a particular web instance.

1

u/femio 17d ago

As an aside, I'm willing to bet you can significantly reduce that 40 minutes if all it's doing is turning CSVs into some other format. Regardless how big the CSVs are

1

u/voprosy 17d ago

You mentioned workflow. 

Is the job running for 40 minutes continuously? Or it’s a process that takes at most 40 minutes to conclude (jumping from one stage to another, with users intervening in between) ?

1

u/zenspirit20 17d ago

We wanted to use DuckDB for customer facing analytics and sadly Vercel didn’t had the support to run DuckDB nor a good way to integrate with MotherDuck because it required a long running service . We moved over to Render and nice side benefit has been that it has been economical for our team size compared to Vercel.

1

u/BeautifulOkra8938 17d ago

railway is the safest bet for a Next.js app with long-running workers. It lets you split the frontend and worker into separate services within one project so they share the same Postgres but have independent health checks and restart policies. This stops your 40-minute CSV jobs from crashing your whole site or timing out like on serverless platforms

1

u/MeasurementGreat5273 16d ago

Keep the Next.js app where it is or on a small VPS, and run the worker as its own process with Postgres as the queue. Something like pg-boss or graphile-worker. A 40 minute job then survives restarts, because it picks up from the table instead of dying with the process. Your box falling over while you slept is probably a missing process manager, systemd or Docker with restart: always fixes most of that

1

u/AnswerVinod 16d ago

This is the exact point where Vercel stops being the easy answer. Once you have a Postgres DB, file uploads and a 40 minute worker, you are basically running a backend, not a frontend with extras. I would move the whole thing to one VPS or a small Railway or Render setup where the Next.js app and the worker live together and talk to the same Postgres. Keep the worker as a separate Node process with a queue like BullMQ so a crash does not take the app down with it. And chunk those CSV jobs too, a single 40 minute run will bite you on any platform when something fails halfway through.

1

u/bunchies_cc 16d ago

VPS. Digital Ocean + Bitbucket pipeless has been working great for us.

1

u/leoniebuilds 15d ago

Since you want one platform, I'd run the Next app and the CSV processor as separate services, with the processor as a long-lived worker rather than a request/function. Make sure the job state and uploaded file live outside the worker's filesystem, such as in Postgres and object storage, so a restart can retry cleanly instead of losing progress.

1

u/shafinmarceline 9d ago

For 40-minute CSV jobs, I'd focus on failure recovery before picking the hosting provider.

You can run Next.js and a dedicated worker as separate services in the same Railway or Render project. Let the web app enqueue jobs while the worker handles processing independently.

The important part is making jobs recoverable. Persist progress, handle retries safely, and make report generation idempotent so a worker restart doesn't create duplicate outputs.

I'd also monitor stalled jobs, not just whether the worker process is alive.

Are those 40-minute jobs mostly CPU-heavy transformations, or are they waiting on external APIs and storage?

1

u/Murky_Violinist966 9d ago

Worth splitting this by what the work is, because that's where these platforms differ way more than they do on the fronted side. Anything on a timer , ample-computer has cron and scheduled jobs on every plan with retries and run history. The worker that sits there all day is the part to price on any host, Railway runs that as an always on container and bills on usage, so a process that never stop is metered on RAM and CPU the whole time it runs.

1

u/PuzzleheadedTax7404 7d ago

a 40 minute job was never going to fit in functions, thats not you doing it wrong, its like renting a hotel room by the hour to live in. their own guide lists a job that cant be split and runs past and runs past the max duration as a reason to keep a worker somewhere else. the test for the next host is whether that worker runs as a normal process. ample. computer runs next start and the worker as ordinary processes and builds from source, so no docker images, and the marketplace postgres url keeps working from there or it creates a new database. warp queue jobs in ample-awake so they arent treated as idle

1

u/koigrid_com 1d ago

Disclosure: I work on koigrid, a hosting platform, so weigh this accordingly.

Whatever you pick, the thing that fixes the overnight crashes is the shape, not the host: run the CSV processor as its own long-running worker (not a function), keep the uploaded file in object storage and the job state/progress in Postgres, and make the job resumable so a restart picks it up instead of starting over. Several people above already covered that well (the heartbeat + attempt counter tip is the one people skip).

On the "one place" part: Railway and Render both do app + worker + Postgres in one project. koigrid does too: the Next.js app as a web service, the processor as a worker (no port, no URL, just a container that stays up), managed Postgres and S3-compatible storage, all in one project, and the worker reads the database URL through a reference variable so you don't paste connection strings around. Pricing is by reserved RAM with CPU and traffic included, so a 40-minute job doesn't cost more than a 4-minute one.

Honest caveats: it's a young platform, and if you're happy with Railway's DX there's no reason to move twice.

0

u/[deleted] 15d ago

[deleted] — view deleted comment

1

u/MeasurementGreat5273 15d ago

Do you reclaim jobs when a worker dies mid-run? With SKIP LOCKED alone a crashed worker leaves the row stuck on running. A heartbeat column and a claim query that also takes stale ones fixes it, or pg-boss does that for you

0

u/[deleted] 11d ago

[deleted] — view deleted comment

1

u/MeasurementGreat5273 11d ago

Also bump an attempt counter on every reclaim and make the progress writes conditional on it. A worker that was only slow, not dead, will otherwise keep writing over the one that took the job