News for hackers. Stuff that matters.
Re:Deno 1.28: Featuring 1.3M New Modules by commitpizza on Monday November 14, 2022 @09:28AM (#33594356)
I like what Deno is doing, it also has a bunch of great features. The functionality of it is great and the execution is sharp.

However, my main gripe with Deno is that it's tied to one company and it won't solve issues that it doesn't have. As an example of this, a version of nodes cluster module is not supported so there is no way of running one deno process per cpu which is very bad if you're hosting it yourself and want to utilize the full potential of your hardware.

It also means that if your app is bound to some CPU heavy action, like generating a large excel-file or similar, your app will go down since no requests will be processed due to the single thread nature. Of course, such actions can be solved with a web worker but what if you make a coding mistake which renders an unhandled exception? In this case the app would probably go down and if the end user for example does the same action over and over again (which end users tend to do in frustration), the app will go down again and again.

Deno as a company has probably little interest in solving this as the solution is to run it on their paid service. You could of course have several servers hosting the app, but that gets expensive real quick especially if you are a small shop. Another example is to run the entire app process as web workers but then you need to spin up many processes that all have their own ports which you need to add a load balancer in front of it. This is kind of advanced and adds unnecessary complexity to the app IMO.

Also, if Deno the company company fails, what then will happen to Deno the project?

Re:Deno 1.28: Featuring 1.3M New Modules by homeland221 on Monday November 14, 2022 @09:42AM (#33594604)
Similar with MySQL. As long as the code is open sourced...I'm ok with it...heck MySQL managed to turn into MariaDB and yet many still stick MySQL.
Re:Deno 1.28: Featuring 1.3M New Modules by spion on Monday November 14, 2022 @09:45AM (#33594638)
regarding multiprocess, I think solutions such as kubernetes and similar are the way to go (rolling restarts / updates, autoscaling, advanced load balancing etc) rather than having it managed within the runtime libs

> what if you make a coding mistake which renders an unhandled exception?

AFAIK unlike node, Deno's API is largely promise-based and therefore all unhandled exceptions should become unhandled rejections withou crashing the process - so this should be less of an issue than it is with node (Of course, using older node libraries makes crashes more likely)

Re:Deno 1.28: Featuring 1.3M New Modules by tempest_ on Monday November 14, 2022 @09:51AM (#33594745)
There is an ocean of distance between wanting to use all the cores on a CPU and spinning up (or paying for) the monster abstraction that is kubernetes.
Re:Deno 1.28: Featuring 1.3M New Modules by spion on Monday November 14, 2022 @12:02PM (#33597146)
Just as a point of full disclosure, I'm the author of recluster (https://github.com/doxout/recluster) and its accompanying modules (such as https://github.com/spion/sticky-listen) and I also have some experience with managing k8s by myself - so I have some experience with both approaches.
Re:Deno 1.28: Featuring 1.3M New Modules by commitpizza on Monday November 14, 2022 @09:51AM (#33594750)
> AFAIK unlike node, Deno's API is largely promise-based and therefore all unhandled exceptions should become unhandled rejections withou crashing the process - so this should be less of an issue than it is with node

Perhaps you're right, I have not tried this out in Deno-land so I cannot say wether this actually applies to Deno the same way.

I just know that I got burned by this exact issue in node and I think this can be a security issue that people usually don't really think about. If you know that some api is a node api, if you manage to find a bug that is crashing the process one could probably script it to trigger it to crash over and over again. Even if it restarts quickly, usually it takes a second or and in that time one could bring the entire api down.

I am not aware of any instance that this have been used against some api in practice but most other languages handle this much better than node does and the javascript way of crashing on error is one of the things that made me question using javascript for backend services at all.

Regarding the kubernetes... no thanks. I would not go into that beehive unless forced. I didn't like the complexity increase of adding a load balancer and that is like a drop in the ocean of the complexity that is kubernetes.

Re:Deno 1.28: Featuring 1.3M New Modules by spion on Monday November 14, 2022 @10:37AM (#33595533)
k8s is not really that complex by default, despite all the complexity hype around it (if you look carefully you'll notice the people saying this more often than not have a serverless SaaS to sell). You can run something simple such as microk8s on VMs and get better results more quickly than any manually managed process manager and/or load balancer.

You can, of course, make it more complex by piling a ton of stuff on top of it, and most cloud provider offerings do that. But its not required.

Re:Deno 1.28: Featuring 1.3M New Modules by joelg236 on Monday November 14, 2022 @09:57AM (#33594863)
You can use PM2 with Deno
Re:Deno 1.28: Featuring 1.3M New Modules by commitpizza on Monday November 14, 2022 @10:09AM (#33595062)
Somehow I feel like if you need to install Node to run Deno, you may as well just run Node from the beginning.
Re:Deno 1.28: Featuring 1.3M New Modules by doorman2 on Monday November 14, 2022 @10:08AM (#33595050)
You could solve the resource starvation issue by running multiple instances of your app and binding to a port using the SO_REUSEPORT option. This will allow multiple instances of your app to use the same port.

This option is also quite good for deployments as you can have instances stop reading from the port while client traffic is still being served from other instances on the port. This works well for HTTP requests, but less so for something like gRPC.

Re:Deno 1.28: Featuring 1.3M New Modules by commitpizza on Monday November 14, 2022 @10:15AM (#33595147)
Just out of curiosity, how would you configure that in a systemd configuration file?
Re:Deno 1.28: Featuring 1.3M New Modules by doorman2 on Monday November 14, 2022 @10:22AM (#33595262)
You use the setsockopt system call. This is an example in C:

    int sfd = socket(domain, socktype, 0);

    int optval = 1;
    setsockopt(sfd, SOL_SOCKET, SO_REUSEPORT, &optval, sizeof(optval));

    bind(sfd, (struct sockaddr *) &addr, addrlen);
In Go, you can use syscall.SetsockoptInt. Most languages have a way of setting this option. You have to create the socket yourself and pass it into your HTTP server in most cases, but it depends on the library.

Edit: oh sorry, you meant when systemd is opening the port for you. It looks like you can set ReusePort=yes in your configuration? https://www.freedesktop.org/software/systemd/man/systemd.soc...

Re:Deno 1.28: Featuring 1.3M New Modules by jbaczuk on Monday November 14, 2022 @10:21AM (#33595252)
why not just build multithreading into deno? Is this only a paid feature?
Re:Deno 1.28: Featuring 1.3M New Modules by hayd on Monday November 14, 2022 @10:16AM (#33595178)
There was some discussion of using rayon for CPU heavy ops... I'm not sure what makes excel generation CPU-intensive and blocking? (I wonder if it can stream.)