Imagine buying a new desktop computer, not the most expensive but a good performing one, and setting it up at home to serve some kind of cloud services. With its cpu fully utilized 24x7, I bet buying equivalent compute at AWS would be crazy expensive per month.
Of course there are many reasons most people don’t use desktop systems as home servers, but I bet there are a few scenarios where it could payoff.
One example might be a bootstrapped startup tight on cash flow, with cpu biased workload, so ISP bandwidth and local disk throughput didn’t bottleneck before the compute did. And it couldn’t be a mission critical service, something where some maintenance windows wouldn’t kill your reputation.
Finally you’d need a way to really minimize admin/devops costs. That kind of work doesn’t take many hours to kill your savings not to mention opportunity costs.
https://news.ycombinator.com/item?id=4063929
Project is a React client and express backend. It's built and tested dockerized. We use testcafe and Chrome headless, so more memory is always useful for parallel builds.
Likewise, the distinguising factor between multi-threading and multi-processing is shared memory, i.e. again, the speed of communication.
Multi-threading does well for some problems, but often, multi-machining or multi-processing is sufficient, which is why so many runtimes don't really do multi-threading: Node.JS, Python, Ruby.
This might have been what you meant when you said the runtime isn't really multi-threaded - but since the CPython ecosystem rests so heavily on C code, in practice multithreading is a good solution a lot of the time.
I don't understand why people keep insisting that the lack of multi threading support is a Javascript problem when there are better and more scalable ways of using your machine resources.
What if you have a large shared in-memory data structure that you want to update with lots of irregular translations in parallel? Like many graph problems? How are you going to do that with multiple containers? As in industry we just don't understand how to distribute that kind of problem effectively.
One of the reasons Node is successful is the simplicity of single threaded code. Way easier to reason, I would question the usage of Node if you are doing something CPU bound with it. You can use golang or C# with tasks for that.
Use C++.
If you ever decide to scale and distribute it for real save the state in a database and orchestrate containers. For this solution i would recommend using Node.js or Go.
Not ideal, but not too bad either.
My app should be stateless and scale by replication. This is the most efficient solution in every possible way.
Containers don't cost meaningfully more than threads unless you create expensive unique resources for each one.
It works for specific types of work, but not necessarily as a low cost abstraction unless you pre-thread. In other words, it works well for some cases where threads are used, and horribly for others.
1. Setting up containers and the communication between them is really complex - it also only makes sense for a deployed, long-running, server process. 2. Communication between containers is very expensive. You're never going to beat an in-process pointer to shared memory.
Web workers would make a lot more sense for most javascript programs.
2 - That is only true if the your bottleneck is on communication somehow. Usually it is not.
And a huge advantage: You will write stateless and easy to scale apps that do not care how the machine resources are being handled.
https://github.com/MicrosoftArchive/redis/issues/556 (Jun-Sep 2017)
>Why do MS always do this??? Start something, announce it aloud "we are now open source, we are now this and that blah blah" then quietly do a 360 and moonwalk away
https://en.wikipedia.org/wiki/Moonwalk_%28dance%29
>moves backwards while seemingly walking forwards
It's actually a near-perfect analogy here, where actions speak louder than words re: Microsoft's commitment to maintaining adaptations of existing open source projects. I think the example provided is enough to trigger a careful analysis before jumping in, and I would love to see counter-examples to help balance the evaluation.
(Please note: very specifically requesting counter-examples of Microsoft-official, intended for production, open source repositories demonstrating long-term maintenance of tweaks of/dependencies on established open source projects that for whatever reason were never up-streamed.)
They built this to scratch an itch, then they opened the source, but that's still not enough?
If the maintainers of a project don't manage the project properly and other people think they can do a better job, Open Source gives you the right to fork. And this social contract is an incentive for the maintainers to do a good job in order to not lose control.
On the other hand the maintainers have no contractual obligation to keep supporting the project.
When maintainers stop supporting the project, the code is still there to be picked up if there's enough interest. That's powerful, but also distributes the responsibility to all interested parties.
If no new maintainers show up to fork the project, then maybe it's OK for the project to die.
> They built this to scratch an itch, then they opened the source, but that's still not enough?
I'm honestly not sure where this question is coming from. The issue I linked is on a port of Redis to Windows done back when Microsoft Open Technologies was temporarily spun out as a subsidiary, and is one of many there reflecting frustration at Microsoft's mismanagement of the project, especially lack of communication regarding long-term support. It serves as a recent example of how Microsoft drops a low-priority open source project.
Microsoft is building a strong track record with open source projects that they completely control, but less so when they don't. I believe this is relevant here because of Napa.js's tight coupling with Node.js.
As people pushed the limits of Python's performance and were only met with answers like "use C for fast code, the GIL is probably never going to be removed", Go and Swift emerged, clearly intending to provide a Python-like development experience with performance characteristics more similar to Java, including the ability to run real threads.
Other runtime developers should pay attention and be careful not to fall into the same trap.
Threads are great also when you need to do CPU intensive calculations such as processing an audio file or number crunching. That's what NapaJS seems to be geared towards in fact.
Seriously... when publishing a project like this, the authors ought to give a least a bit of insight into their motivation. Their examples include calculating Fibonocci in parallel, not exactly breakthrough.
But for node cluster's case, if we need to load a data set for a worker to serve request, it has to be loaded on each process. While the multi-threaded model will have only one copy.
Edit: I would question usage of Node if everything you are doing is CPU bound. I think people started down-voting me without going through docs, I mean just read this documentation page and tell me this is right https://github.com/Microsoft/napajs/blob/master/docs/api/mem...
> As it evolves, we find it useful to complement Node.js in CPU-bound tasks, with the capability of executing JavaScript in multiple V8 isolates and communicating between them.
Not everything MS did was evil.
https://en.wikipedia.org/wiki/River_Trail_(JavaScript_engine...
Another attempt (although a different approach) is here : https://github.com/tc39/ecmascript_sharedmem
Hopefully, Microsoft will learn from the errors of others. Interestingly, napa is build on V8, not on MS own javascript engine.
https://webkit.org/blog/7846/concurrent-javascript-it-can-wo...
1. It is exposed as a nodejs module, but some other modules may be at conflict because they may wrongly assume that they are the only thread running. E.g., some modules may be using global variables in C++.
2. Still, it doesn't support fast immutable communication (structural sharing) to other threads through shared memory.
Does Java offer cross-thread shared memory? Go, Haskell, Python, etc.?
Python supports threading but is not very useful due to the infamous GIL. However, multiprocessing is usually a decent alternative and it supports shared memory on forking (copy on write, though). Also you can use mmap easily for IPC.
I wrote this up: https://news.ycombinator.com/item?id=15499629
“I believe this to be a basis for designing very large distributed programs. The “nodes” need to be organized: given a communication protocol, told how to connect to each other.” ttps://www.americaninno.com/boston/node-js-interview-4-questions-with-creator-ryan-dahl/
As far as I can see, cluster workers are all uniform (no task-specific pools) and cluster has no broadcast (just `worker.send(message)`.)
I would assume this would benefit desktop JS most, so it'd undoubtedly help Electron apps.
EDIT : There's a better explanation at https://github.com/Microsoft/napajs/wiki/Why-Napa.js
For anything else, IMHO the use-case will be so narrow, that I wonder how MS will justify the development resources for maintaining it.
"Use Isolates for secure, concurrent apps. Spawn an isolate to run Dart functions and libraries in an isolated heap, and take advantage of multiple CPU cores." -- https://dart-lang.github.io/server/server.html
Then, this has a lot of compatibility issues, and release-wise it will be hell. I don't think this is a good idea.