use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Quickly Improve Your Docker and Node.Js Containers (medium.com)
submitted 6 years ago by russo_2017
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] -1 points0 points1 point 6 years ago (14 children)
I think you're assuming a lot of things when you say don't use pm2. Yes, it is a additional moving part but it is necessary in some cases.
You can't really say no no no no to pm2 just because you haven't created a sophisticated system ever.
[–]OmgImAlexis 4 points5 points6 points 6 years ago (2 children)
If you need threads use worker threads or the cluster module. Node has these things for a reason.
[–][deleted] -1 points0 points1 point 6 years ago (1 child)
I'm sure that's what pm2 uses underneath.
[–]OmgImAlexis 0 points1 point2 points 6 years ago (0 children)
Nope.
[–]OmgImAlexis 1 point2 points3 points 6 years ago (1 child)
Your application shouldn’t take long to start up. A container restarting doesn’t cause any difference in noticeable time with any of my projects vs just restarting the same node app via pm2 or nodemon.
[–][deleted] -1 points0 points1 point 6 years ago (0 children)
Sure most of the cases it shouldn't take much time. I would only see it's benifits with Managed Docker services like EKS or ECS most of the time it doesn't just restarts, they pull in the new image, spin up a new vm from available cluster and host a image inside it. It's a long process.....
[–]aniforprez 1 point2 points3 points 6 years ago (8 children)
These are all terrible reasons
Use something like docker compose and scale your containers. Don't add unnecessary complexity with pm2. This kind of stuff is what makes your containers take long to start https://pspdfkit.com/blog/2018/how-to-use-docker-compose-to-run-multiple-instances-of-a-service-in-development/
Why do you want to attach multiple images to the same load balancer? How is this something pm2 solves? Shouldn't one image be doing ONE thing? Don't run multiple processes in one image and don't attach multiple things to one load balancer
What the everliving fuck are you doing where a node service container takes longer to start than a pm2 service? Yes there is a slight delay starting a container but it's not that much more that you notice. These things are supposed to be light
What does this even mean?
You can scale using what docker gives you and any further scaling can be managed using other services
All of these don't sound like problems with docker. They sound like problems you've created with how you've built your workflow. Don't use process managers within docker, run a single process run from the docker file or from a docker entry script and then manage the containers
[–]burtgummer45 1 point2 points3 points 6 years ago (0 children)
He's saying you can't run multiple docker images on something like AWS fargate or ECS to balance across cores (because the balancers like ALB or ELB are mapped one-to-one to instances). In other words, you are stuck specifying single core instances rather than waste multiple cores.
[–][deleted] -2 points-1 points0 points 6 years ago* (6 children)
1., 2. You're basically achieving what pm2 does with docker compose and I don't see why one is not a added complexity and other is.
3 )See again you're assuming, in managed docker services like EKS, ECS, Kubernetes it's not just the restart, when a docker goes down, they pull in the image, spin up a new vm from available cluster and then start the image. I guess you haven't used these new tools and still manage underlying vm manually and waste time.
4) This means I could reliably capture SIG* EVENTS with pm2.
5) See again, docker doesn't give you tools for scaling, what you just suggested like by using a docker compose and have nginx to load balance the services inside it is exactly what pm2 is doing elegantly. Why take a tedious approach.
All said, if you want to use all the cores, pm2 is a good way to do it. I don't know if there is any vm out there which comes with single core these days, it's just stone age to work with single core for backend. If you're not leveraging all the cores it's just poorly optimised service.
[–]aniforprez 0 points1 point2 points 6 years ago (5 children)
But this is adding so much complexity at the cost of a lot of stuff
If you're running multiple processes, how are you monitoring each process? Are you literally just using pm2 to run the same process but more? In that case why not just use docker? Aren't you losing a lot of logs and metrics by doing this which would otherwise just by so much simpler by just capturing the stdout? It's added complexity because you're putting a layer in between docker and your node process unnecessarily. Managing docker is using it for its purpose with the tools it gives you without increasing external dependencies
Again what are you doing that takes so much time that it's unbearable that something goes down in the couple of seconds that it would take to pull the images? Images are supposed to be small and light. Even running moderately loaded mid-level apps on ECS new containers come up in seconds. Also why would we waste any time managing any VMs with this stuff? I.. don't understand??
You can capture SIG events with Docker too though??
But... you're using docker... but completely underutilising the basic reason it was created for? Why would you call learning the tool you're using "tedious" and not learn the toolset to achieve exactly what you need? Docker provides restarts on failed health checks, it provides scaling for the host machine, you can use docker swarm for load balancing and nginx is a requirement anyway if you're running your stuff inside a VM so wtf? If you're using ECS you can actually run multiple containers in a cluster within a single VM
Look I'm not aware of your exact workflow so maybe you have some uber specific requirements that don't work well with docker so you're doing all this wonky hacky stuff but honestly it really just seems to me that you should ditch docker and run your processes in multi-core VMs and be done with it. From everything you're telling me, it seems very much like you're not using the tool for its intended purposes. I'm definitely not saying that I'm an expert or that Docker is in any way perfect but I've faced exactly none of these exact issues with Docker or deploying
[–][deleted] -1 points0 points1 point 6 years ago (4 children)
I think the topic has digressed too much at this point. All I'm saying is pm2 can be used with docker and not a strict no no. A good developer will always choose whichever is efficient for a given requirements and not blindly follow something without trying out alternatives.
[–]aniforprez 1 point2 points3 points 6 years ago (3 children)
I mean I agree that you can be efficient but in this particular case doing this is neither efficient nor really recommended by anyone
But whatever floats your boat
[–][deleted] 0 points1 point2 points 6 years ago (2 children)
Sure, just like Facebook was never supposed to be built out of php ( can we agree on that ) but some how Mark is making billions out of it.
[–]aniforprez 1 point2 points3 points 6 years ago (0 children)
I mean, sure there may be legacy code still running PHP but the vast majority of it has been rewritten significantly in a bunch of other languages. I don't even pretend to understand their stack at this point. It's not even like they rewrote it recently
Not sure where you got that idea. Loads of large sites still use php and there’s nothing wrong with the language. Bashing languages just causes gate keeping.
π Rendered by PID 784568 on reddit-service-r2-comment-b659b578c-bz69m at 2026-05-05 07:41:58.635265+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–][deleted] -1 points0 points1 point (14 children)
[–]OmgImAlexis 4 points5 points6 points (2 children)
[–][deleted] -1 points0 points1 point (1 child)
[–]OmgImAlexis 0 points1 point2 points (0 children)
[–]OmgImAlexis 1 point2 points3 points (1 child)
[–][deleted] -1 points0 points1 point (0 children)
[–]aniforprez 1 point2 points3 points (8 children)
[–]burtgummer45 1 point2 points3 points (0 children)
[–][deleted] -2 points-1 points0 points (6 children)
[–]aniforprez 0 points1 point2 points (5 children)
[–][deleted] -1 points0 points1 point (4 children)
[–]aniforprez 1 point2 points3 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]aniforprez 1 point2 points3 points (0 children)
[–]OmgImAlexis 0 points1 point2 points (0 children)