News for hackers. Stuff that matters.
Re:The beauty of CGI and simple design by scotty79 on Saturday January 07, 2023 @06:36AM (#34287169)
> a persistent process makes everything much simpler ...

I started with PHP and never trusted persistent processes for anything.

What if your persistent process hangs or crashes for whatever reason?

Is your whole site down then, not just the part with the bug?

The only site I ever made in persistent process paradigm was in ASP.NET and it didn't cause too many problems but it was more of an app, not website, with limited number of logged in users and pretty much no anonymous/guest part.

Re:The beauty of CGI and simple design by wizzwizz4 on Saturday January 07, 2023 @07:00AM (#34287271)
> What if your persistent process hangs or crashes for whatever reason?

You've got the same problem with your web server, and your operating system kernel. Simply write a program that can't hang or crash – at least, not due to an application bug. It takes attention to detail, but this is a lot easier than writing a program that always behaves correctly; if you limit the syscalls you make, use timeouts appropriately, and don't segfault, it's often achievable.

Re:The beauty of CGI and simple design by scotty79 on Saturday January 07, 2023 @08:27AM (#34287785)
I don't think any mainstream framework in any mainstream language has these kinds of precautions.

Rails? Django? Express? .NET? Do they kill long running requests so they don't affect whole application?

Can the application still mostly work despite syntax error in one of the files?

Another thing is level of trust. I trust Linux kernel, I trust apache webserver. But some webserver written in scripting language few years ago? Not so much.

Re:The beauty of CGI and simple design by Semaphor on Saturday January 07, 2023 @08:39AM (#34287860)
> .NET? Do they kill long running requests so they don't affect whole application?

Not sure about the built-in .net server, but IIS does exactly that. It supports timeout and error/time based restarts for the persistent process.

Re:The beauty of CGI and simple design by alerighi on Saturday January 07, 2023 @02:00PM (#34291358)
Well try in a nodejs server to put a `while(true);` in a request handler. Do you know the answer? The whole process blocks, since nodejs is single process.

I trust more the code that I wrote than the code written from others... not because I'm better than others, but because I know what it does, and I know how to fix it if it breaks.

Re:The beauty of CGI and simple design by scotty79 on Saturday January 07, 2023 @02:18PM (#34291562)
It still wouldn't hurt if the framework just killed it after 3 seconds with timeout message.
Re:The beauty of CGI and simple design by rusebor on Sunday January 08, 2023 @02:32AM (#34296939)
Erlang
Re:The beauty of CGI and simple design by ilyt on Saturday January 07, 2023 @11:25AM (#34289534)
> I started with PHP and never trusted persistent processes for anything.

Well it's (maybe was, it did get a bit nicer over years but old shit code is still there) terrible language so no wonder you have no trust.

> What if your persistent process hangs or crashes for whatever reason?

depend on language. For example in Go (in most frameworks at least) panic() in goroutine handling request will just... nuke that request and nothing else. Sure, memory leaks can be issue if the code is terrible but essentially restarting app after every request is just shitty workaround for shoddy code.

That's how most other handle code. Other, that do multi-core processing badly like Ruby, just spawn multiples of server so it isn't really that different from PHP model, you get "supervisor" that spawns few processes of app and feed them requests, if one dies it just gets restarted.

Re:The beauty of CGI and simple design by wwweston on Sunday January 08, 2023 @11:04AM (#34300191)
> Well it's/twas terrible language so no wonder you have no trust

The reason someone who was shaped by working in PHP probably has less to do with any specific shortcomings of it as a language and more to do with the fact that overwhelming execution model is single-request shared-nothing.

This conceptual model works well enough (especially for the web) there's entire cloud services built around recreating it for other languages called "serverless," and they do well because it's a useful simplification which means the issues associated with persistent processes become somebody else's problem.

Devs being what we are, of course there's always those of us who prefer certain things to remain our problem. This is fortunate as someone needs to assume problems like long-running processes in order for others to make it somebody else's problem. Software development has some things in common with comparative advantage.

Re:The beauty of CGI and simple design by kefka_p on Sunday January 08, 2023 @01:27PM (#34301639)
Fault tolerance was how Next branded it, IIRC. If an instance of a long running process doesn’t communicate with an external monitor, then it’s assumed to have hung or crashed at which point it is restarted by the external tool. Or at least that’s how things were done in the early/mid 90s. Like techniques are employed by Node apps these days, and undoubtedly many others.