"We spin up 50 node containers" <-- WTF?! or WTF!?
-
I was talking with a NodeJs shop, and they explained their deployment process. I didn't take great notes, but I was baffled.
They have a web site that they believe will get a shitton of traffic, so they designed their software and infrastructure to scale.
Each web server is a virtual server that has Docker installed. That server then hosts dozens (generally 50) of containers that run nodejs and their application. There virtual server also has some software (forgot the name, but it was one of those silly dev product names) that decides which node container to send the request to.
Then the have a load balancer that decides which web server to send it to.
Their contention was that running dozens of nodejs instances is better, because each node process only uses a single thread, and this way it's multi threaded.
This leads me to wonder...
- is nodejs really that deficient of a hosting platform that it can't utilize worker threads to process reqeusts?
- Are they really that incompetent that they managed to build a doubly-load balanced thing so they could put on their resume that they know how to use as many stupid dev tools as possible?
-
@apapadimoulis said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
is nodejs really that deficient of a hosting platform that it can't utilize worker threads to process reqeusts?
yes. Every node.JS process is single-threaded on an event loop. You're expected to run multiple instances if you have a lot of traffic, it will not scale outward at all. You then treat the 50 docker containers like 50 worker threads.
-
NodeJS is pretty nifty but it really needs to overcome its threading limitations and provide a better way to share data between instances so it can scale in a non-WTF manner.
-
@apapadimoulis said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
Each web server is a virtual server
"Virtual server" as in a virtual machine? So this whole mess could potentially be running on a single physical server, if one were to be optimistic about the WTF-ery involved in this setup?
-
@apapadimoulis said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
is nodejs really that deficient of a hosting platform that it can't utilize worker threads to process reqeusts?
depends on how you're using it, but yeah. one processing thread. to scale out you run multiple instances.
honestly though that setup is overkill. you don't need docker for that, just spin up the instances on the host VM, configure nginx to proxy to the instances correctly, if you need multiple VMs you configure the load balancer to proxy the API requests to the various nodes in the cluster (that then farm it out to the individual workers they run) and to serve static resources itself.
no need for docker or fancy bullshit load balancing apoplications. just use what's built into nginx (or apache if you decide to use that)
the whole thing reads to me like resume porn for a developer that's too full of themselves.
-
@Yamikuronue said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
@apapadimoulis said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
is nodejs really that deficient of a hosting platform that it can't utilize worker threads to process reqeusts?
yes. Every node.JS process is single-threaded on an event loop. You're expected to run multiple instances if you have a lot of traffic, it will not scale outward at all. You then treat the 50 docker containers like 50 worker threads.
You can have worker processes without a docker container for each one.
-
@apapadimoulis said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
is nodejs really that deficient
You're posting here and you still feel the need to ask?
-
@accalia If you're gonna run a load balancer anyway, can't you just have your node workers listen on port 8000 through 8049 and have the front load balancer handle it?
-
@PleegWat said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
@accalia If you're gonna run a load balancer anyway, can't you just have your node workers listen on port 8000 through 8049 and have the front load balancer handle it?
hmm.... actually, yeah. that would be the better way to do it......
why did i think there needed to be a second layer in there?
there was a reason for it.
probably a stupid reason, but it was my reason gosh darne it!
-
@cvi said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
@apapadimoulis said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
Each web server is a virtual server
"Virtual server" as in a virtual machine? So this whole mess could potentially be running on a single physical server?
Probably a 10 year old Dell laptop.
-
@Yamikuronue said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
Every node.JS process is single-threaded on an event loop. You're expected to run multiple instances if you have a lot of traffic, it will not scale outward at all.
of course it works that way
@mott555 said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
NodeJS is pretty nifty but...
I feel the same way about a Speak & Spell®, though there was at least competent engineering behind that.
-
Hey, I'm a frontend dev and I need to code something on the backend but I don't know any other languages beside JavaScript.
I know, I'll just use JavaScript on the backend !!!
Signed: NodeJS inventor
Using a language designed to run in a browser on the frontend to code the backend is the Real
-
@accalia said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
honestly though that setup is overkill. you don't need docker for that, just spin up the instances on the host VM, configure nginx to proxy to the instances correctly, if you need multiple VMs you configure the load balancer to proxy the API requests to the various nodes in the cluster (that then farm it out to the individual workers they run) and to serve static resources itself.
That was my first thought, but they said something about the processes interfering with eachother and not having enough isolation, needing temporary/working directories, that stuff. Plus their whatever-the-fuck Docker manager thingy would automatically scale based on demand, otherwise they'd need to statically have exactly 50 processes.
They already demonstrated a lack of competence by choosing NodeJS, so anything beyond that is questionable.
-
@TimeBandit said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
a language designed to run in a browser
"Designed". That is an awfully generous way to describe JavaScript.
-
@apapadimoulis said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
I feel the same way about a Speak & Spell®, though there was at least competent engineering behind that.
Speak & Spell is no See 'n Say.
-
This entire application makes me seethe with rage and nausea
-
@apapadimoulis said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
That was my first thought, but they said something about the processes interfering with eachother and not having enough isolation, needing temporary/working directories, that stuff.
oh, so not only did they use nodejs where it shouldn't have been used, but they did so imcompetently......
fantastic.
the former they could have recovered from, the latter is inexcusable
@apapadimoulis said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
Plus their whatever-the-fuck Docker manager thingy would automatically scale based on demand, otherwise they'd need to statically have exactly 50 processes.
they don't need docker for that. they can have a dynamic load balancer in place and just spawn workers as needed. both nginx and apache do that natively for webworkers. setting it up so they inteligently proxy the requests to the currently running nodes is tricky, but totally doable natively (ish, you might need a tiiiiiiny bit of bash scripting to glue everything together)
@apapadimoulis said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
They already demonstrated a lack of competence by choosing NodeJS, so anything beyond that is questionable.
as a NodeJS developer myself i really feel like i should be insulted by that comment but..........
-
@accalia said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
@apapadimoulis said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
They already demonstrated a lack of competence by choosing NodeJS, so anything beyond that is questionable.
as a NodeJS developer myself i really feel like i should be insulted by that comment but..........
I won't since I know it's true
-
@accalia said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
as a NodeJS developer myself i really feel like i should be insulted by that comment but..........
Whoops, my bad. I want to help foster a harassment-free environment here, and will try to keep in mind that "technology choice" is now a protected class.
-
Is there any point in running more threads than CPU cores? Node is supposedly asynchronous, so its "main" thread should not block on UI.
Do they have 50 CPU cores?
-
@TimeBandit said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
Hey, I'm a
frontendweb dev and I need to code something on the backend but Idon't know any other languages beside JavaScripthave already implemented it on the frontend and don't want to port thousands of lines of code to another language and keep two codebases in sync.FTFY
-
@mott555 said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
NodeJS is pretty nifty but it really needs to overcome its threading limitations
...and JavaScript. They need to overcome JavaScript. Or ditch it. They should make a Node.NET!
-
NodeJS is awful for any server stack. It's not at all scaleable, you have all the prototype object WTF-ness JavaScript has, and if you're writing a complex app, which is common in server-side stuff, you're going to find it difficult to maintain. The only thing that might make server-side JS marginally tolerable is if you decided to use TypeScript or something, but even then, you might as well choose something else.
Oh, also, NodeJS just crashes if you have an unhandled exception. No, it doesn't just log an error and continues with the next request. It has to be restarted. So, if you have 50 node containers and there's some bug in your software that results in an unhandled exception under some weird circumstance, those containers will start to die one by one.
-
@Adynathos said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
Is there any point in running more threads than CPU cores?
Yes; you can have threads waiting on things like database calls, etc., that aren't constrained by I/O bottlenecks; regardless, the OS can manage I/O bottlenecks a heck of a lot better than your code (especially if it's JavaScript).
@Adynathos said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
Node is supposedly asynchronous
In the same sense that a Speak & Spell is a word processor, Node is asynchronous.
-
@TimeBandit said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
@accalia said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
@apapadimoulis said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
They already demonstrated a lack of competence by choosing NodeJS, so anything beyond that is questionable.
as a NodeJS developer myself i really feel like i should be insulted by that comment but..........
I won't since I know it's true
well....... i do it because it's fun, not for profit so........
yeah. it's pretty true.
@apapadimoulis said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
@accalia said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
as a NodeJS developer myself i really feel like i should be insulted by that comment but..........
Whoops, my bad. I want to help foster a harassment-free environment here, and will try to keep in mind that "technology choice" is now a protected class.
PFFFFFFFFFFFFFT! what is this, The Daily Politically Correct?! If so, please show me where the exit is so i can throw myself overboard!
/me is laughing her ass off right now.
-
@apapadimoulis said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
Yes; you can have threads waiting on things like database calls
As far as I understand the Node way of doing things (don't have much experience with it), is that you would register a callback which would be called when the DB response comes back. So your main thread is only doing all those callbacks, while some other mechanisms (probably hidden threads) provide the events.
-
@apapadimoulis said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
is nodejs really that deficient of a hosting platform that it can't utilize worker threads to process reqeusts?
Yes.
@apapadimoulis said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
Are they really that incompetent that they managed to build a doubly-load balanced thing so they could put on their resume that they know how to use as many stupid dev tools as possible?
You've been doing this for a while...you host a website that showcases this exact sort of thing...and you dare ask this question? Of course they are.
-
@tufty said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
@apapadimoulis said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
is nodejs really that deficient
You're posting here and you still feel the need to ask?
Not just posting here...he owns the place.
-
@TimeBandit said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
Using a language designed to run in a browser on the frontend to code the backend is the Real
ITYM using a language that was supposed to make a monkey wave on a webpage.
-
@boomzilla said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
@apapadimoulis said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
I feel the same way about a Speak & Spell®, though there was at least competent engineering behind that.
Speak & Spell is no See 'n Say.
See 'n Say is no Sit 'n Spin.
-
@apapadimoulis said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
They already demonstrated a lack of competence by choosing NodeJS, so anything beyond that is questionable.
Right? It's like anybody that chooses anything other than .NET is incompetent.
Filed under: ok, anybody that chooses JavaScript, Ruby or PHP. Or a masochist, vide @Arantor
-
@apapadimoulis said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
"technology choice" is now a protected class.
-
@Polygeekery said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
Not just posting here...he owns the place.
Yeah, I know. Just realised who I replied to :)
-
@apapadimoulis said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
is nodejs really that deficient of a hosting platform that it can't utilize worker threads to process reqeusts?
It has threads, but none that you access. It spins off threads in the background to process http requests, disk reads, other IO stuff. All the code that you write runs in a single thread, though.
To fully utilize node, all you need is spin up the same number of instances as your number of CPU cores. Node even has its native functionality to help you do that (node cluster). No docker required.
@apapadimoulis said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
Are they really that incompetent that they managed to build a doubly-load balanced thing so they could put on their resume that they know how to use as many stupid dev tools as possible?
Yes.
-
@kt_ said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
@mott555 said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
NodeJS is pretty nifty but it really needs to overcome its threading limitations
...and JavaScript. They need to overcome JavaScript. Or ditch it. They should make a Node.NET!
If someone ever creates Node.NET I will find you and kill you.
-
@apapadimoulis said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
That was my first thought, but they said something about the processes interfering with eachother and not having enough isolation, needing temporary/working directories, that stuff. Plus their whatever-the-fuck Docker manager thingy would automatically scale based on demand, otherwise they'd need to statically have exactly 50 processes.
Do they own their own infrastructure? If so, what's the point of having a dynamic scaling system? They still have to pay for all the servers, whether they run 1 docker or 50.
And if they are on some PaaS, you'd think the platform would provide provisioning/scaling support.
Maybe I'm missing something.
-
@The_Quiet_One said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
Oh, also, NodeJS just crashes if you have an unhandled exception. No, it doesn't just log an error and continues with the next request. It has to be restarted. So, if you have 50 node containers and there's some bug in your software that results in an unhandled exception under some weird circumstance, those containers will start to die one by one.
Newsflash, any code crashes if you have an unhandled exception. The thing that "logs and continues with the next request" just adds a try/catch block for every request. Pick a batteries included framework for node, and it works exactly the same way.
-
@cartman82 said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
try/catch block
Yeah, good luck with that if your database calls drop the entire stack.
-
@cartman82 said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
Newsflash, any code crashes if you have an unhandled exception. The thing that "logs and continues with the next request" just adds a try/catch block for every request. Pick a batteries included framework for node, and it works exactly the same way.
If you are using NodeJS as a web server, it's ridiculous to expect the entire server to go down if an unhandled exception occurs. That's a shitty web server if that's the case.
-
@ben_lubar said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
Yeah, good luck with that if your database calls drop the entire stack.
Try/catch locally, check arguments in callbacks. Or use promises. Whatever.
If your app crashes, it's your own fault. Program better.
-
@cartman82 said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
Pick a batteries included framework for node
I don't do web, but my understanding from reading here is there is no batteries-included option. Except the ones that include one of every size battery of course.
-
@dcon Nah, you use things like
forever
orpm2
to restart after an error.
-
@dcon said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
I don't do web, but my understanding from reading here is there is no batteries-included option. Except the ones that include one of every size battery of course.
There are, but only uncool sourpusses use them. Real node.js ninjas artisinaly craft their works of art using only the finest free range single-function modules off npm.
-
@The_Quiet_One said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
it's ridiculous to expect the entire server to go down if an unhandled exception occurs. That's a shitty web server if that's the case.
TIL IIS is a shitty web server.
Filed under: A StackOverflowException will bring down the whole application pool, at least.
-
-
@Polygeekery said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
@apapadimoulis said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
"technology choice" is now a protected class.
-
@dkf said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
@Polygeekery said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
@apapadimoulis said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
"technology choice" is now a protected class.
-
@cartman82 said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
If your app crashes, it's your own fault. Program better.
Yeah, I'm sorry. I really should have reinvented the wheel instead of using other people's code so I could be absolutely certain it wouldn't crash under any circumstances.
-
@apapadimoulis said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
and will try to keep in mind that "technology choice" is now a protected class.
Time to make some offensive jokes
Q: What's difference between a Node.js developer and a pizza?
A: A pizza can feed a family of four.Q:What's the difference between a dollar and a PHP developer?
A:I would care if I lost a dollar.
-
@accalia said in "We spin up 50 node containers" <-- WTF?! or WTF!?:
they don't need docker for that.
No, but Docker makes it much easier, especially as of Docker 1.12.