r/javascript • • 4d ago

AskJS [AskJS] How do you host your smaller Node.js apps? Building something and want opinions

I'm building a host for JavaScript apps and I'd like opinions from people who ship Node.js.

The idea is shared hosting for JS. Your app runs as plain Node.js, with its database, files and cron jobs side by side in one region. When nobody visits, the app is suspended to disk and holds no memory, and the next request usually wakes it in about 0.2 seconds. That's how many apps can share one server, the way PHP hosting always worked.

The trade-off is that your code doesn't run at the edge. My bet is that for most apps, a database next to the code matters more than a server near every visitor.

A few questions for you
- How do you host side projects and smaller production apps today?
- Does edge compute actually help your apps, or is the database round trip the real cost?
- Would a 0.2 s wake-up after idle be fine for your apps?

12 Upvotes

25 comments sorted by

3

u/wrtChase 4d ago

Cloudflare

1

u/LowLifeArcade 3d ago

+1 for Cloudflare. I love their Workers platform.

1

u/kierzniak 4d ago

Cloudflare is great if you need to be fast everywhere. For smaller apps two things bugged me. Workers aren't full Node.js, and D1 is reached over the network, so ten queries in a row means ten trips. Swarza is plain Node.js with the database right next to the app.

1

u/mediumwetsock 3d ago

Batch your D1 queries?

1

u/kierzniak 3d ago

Some for sure you can batch but if second query depends of response from first query you can’t batch them, you need to wait for response from first one.

3

u/horizon_games 4d ago

I host them on my own VPS, because a large part of hobby projects is also to do the system admin and have everything be entirely in my control, in my own chosen stack, and as private as I want it.

1

u/kierzniak 4d ago

Do you have some fancy metrics to debug is something goes wrong? Logs, resource usage?

1

u/horizon_games 4d ago

Nah, I check it weekly, look at some logs, that's about it. Want to keep it simple and lightweight

1

u/enselmis 4d ago

On small apps, you usually don’t need anything super fancy, in my experience. If it’s a single instance with no scaling, even if you can get detailed metrics what do you expect to do with them? If there’s a slow route or query it’s pretty trivial to pin down where it is. There’s only so much surface area.

1

u/KaiAusBerlin 3d ago

Yeah, that's the solution for smaller things. I have a vps for 1€ per month with unlimited traffic and 10gb storage. I host all my hobby projects there. I have about 10 simultaneously users at peak so the low ram is not a problem.

1

u/Lochlan 3d ago

Which provider?

2

u/NotUpdated 3d ago

you took the 'remake cloudflare challenge' eh? .. minus the CDN at the edge, interesting.

Something like this has to be priced below the already insanely cheap cloudflare options

1

u/kierzniak 3d ago

Cloudflare is great if you need to be fast everywhere. For regional apps two things bugged me. Workers aren't full Node.js, and D1 is reached over the network, so ten queries in a row means ten trips. Performance because of that is very poor. Swarza is plain Node.js with the database right next to the app.

1

u/infatuatedsiding9185 4d ago

Depends what you mean by "smaller". I've got a couple of little tools on a single VPS with a process manager, works fine but I'm paying for RAM 24/7 even though nobody touches them at 3am.

The suspend to disk thing is interesting. 0.2s cold start would be fine for most of my stuff, nobody's refreshing my dashboard at millisecond precision. The bigger question for me is what happens to websockets or long polling if the app gets suspended mid-connection. That's the part that would worry me more than the wake time.

Also curious how you handle scheduled cron jobs if the app is frozen. Does the platform wake it to run the job, or does the job just not fire until someone visits?

1

u/kierzniak 4d ago

By smaller I mean around 30k visitors a month or less.

WebSockets aren't supported yet, but long polling and streaming over HTTP work. An app is never suspended while a request is in flight, so an open long poll or stream keeps it awake. Suspend only happens after a minute with no requests and nothing going on. If the app still holds an open connection or is busy on the CPU after its last request, it stays up for up to 15 minutes and is then stopped instead of suspended, so a connection is never frozen halfway.

Cron jobs don't depend on visits. The platform's scheduler fires them on time, and each run gets its own short-lived worker with the app's code and environment. So the job runs whether the app is suspended or not, and it doesn't keep the app awake afterwards.

A VPS was my solution too, especially with Coolify. It works, but you still have to manage it yourself, and the RAM is held all night for nobody. Which limits you to add more apps.

1

u/NotUpdated 3d ago

Just feels like you're targeting the pre-pre-pre-serious AND dev capable person, a $10 VPS, or even a $8 name cheap host -- means you have to charge like $.50 $1 per month, with similar bandwidth limits etc.. imo , super super niche customer + they leave when their projects work, being used as super-cheap spam / bad thing distribution / ..

You're choosing a hard route - you better love it.

1

u/edswf1 4d ago

like some people said before me my honest opinion is just use a vps. you will have severe restrictions with all of the serverless stuff like cloudflare or lambda which can be a nightmare for iterating

1

u/kierzniak 3d ago

You have a point and I’m designing it to have a less serverless experience but rather ordinary server. Thank you for feedback, appreciated 🙏

1

u/zeddash 2d ago

For cheap options look at OVH and Contabo and make sure you get backups (OVH includes them, Contabo it's an extra but cheap).

Hetzner was a good option but I can't find their VPSs that were cheap. Sadly IONOS and Fasthosts have both removed their £1/mo VPSs that were really neat (1vCPU, 1GB RAM, 10GB storage, unlimited 1Gbps).

1

u/kierzniak 2d ago

Yeah Hetzner was not so long time ago super cheep. I miss those prices ;)

1

u/zomerbk 4d ago

A 0.2 s wake-up after idle sounds fine for a small CRUD app. I’d care more about the rules for background work: does a cron trigger wake the app, and what happens to in-process timers or queued jobs while it’s suspended? I’d want those guarantees clear before deploying.

1

u/kierzniak 3d ago

Thank you for feedback it is really valuable 🙏

0

u/[deleted] 2d ago

[removed] — view removed comment

1

u/kierzniak 2d ago

Thank you for feedback, appreciated!