←back to thread

82 points jaysylvester | 3 comments | | HN request time: 0.001s | source

Citizen is a web application framework I started building years ago when I was first learning Node. I've added features and improved stability/performance continuously and finally decided it was worthy of 1.0 status.

I think it might appeal to devs like me (old guys) who came up on app servers like ColdFusion, .NET, PHP, etc. and prefer the server do the heavy lifting. It doesn't dictate anything about your front end, and instead tries to be as flexible as possible in providing whatever output the client might need, whether it's a single fully-rendered HTML view, partials, JSON, or plain text.

Only 2 direct dependencies for terminal commands (commander) and file watching (chokidar). Built-in functionality includes zero-configuration server-side routing, session management, key/value store (cache rendered views, controller actions, objects, and static files), simple directives for managing cookies, sessions, redirects, and caches, and more.

It's been in continuous use on at least one site that receives hundreds of thousands of page views per month, running months at a time without the process crashing. Fairly stable.

Appreciate any comments/feedback/contributions.

Show context
williamdclt ◴[] No.41863081[source]
Congrats! Seems like a considerable project, I appreciate the low-dependency approach.

> hundreds of thousands of page views per month

I’m not sure I’d include that as any sort of perf/stability argument. Even only assuming traffic is only clustered over 8h of the day, it’s 0.1 to 1req/sec. The worst web framework out there in any language probably could handle that

replies(1): >>41863246 #
1. jaysylvester ◴[] No.41863246[source]
That's a fair observation. I only include it because the Node way of doing things seems to be "just let the process crash and restart it", and that's been a tough concept for me to accept. I'm particularly proud of error handling in citizen and want it to be as much like an old-school app server as possible.

I still use pm2 on the aforementioned site just in case though, and maybe seeing that extended process uptime is just a feel-good exercise, but still worth mentioning.

I've been meaning to do real performance testing and keep pushing it off because it's been adequate for my needs.

replies(1): >>41865112 #
2. pier25 ◴[] No.41865112[source]
> the Node way of doing things seems to be "just let the process crash and restart it"

Honestly I've never heard of anyone advocating for this.

PM2 is only necessary if you're running Node in like a VPS where you're in charge of managing the process. In managed solutions like Fly, Google Cloud Run, etc you never really have to care about this. VMs are restarted automatically and it's trivial to have HA with multiple VMs running in parallel.

replies(1): >>41865351 #
3. jaysylvester ◴[] No.41865351[source]
The scenario you described is exactly how I host my sites now (Debian on DO).

I've seen numerous engineers advocate for letting the app crash (or at least gracefully shutting it down), capturing the error, and restarting. Errors crash the Node process by design after all. Perhaps it's not as prevalent as it used to be, but it was certainly considered acceptable and even desirable for a time to let the app crash and restart it with pm2, forever, etc. since an error could leave the app in an unknown state.

citizen has a config option for keeping the app running or exiting the process in the event of an error, so it's up to the dev.