from version 18.14.0, it is advised to use os.availableParallelism() instead of os.cpus().length
@SoftwareDeveloperDiaries7 ай бұрын
Thanks for the hint!
@KinoPM25 ай бұрын
Are you looking for job in Crypto Project? MERN
@vivekbhatti4 ай бұрын
Yes i am @@KinoPM2
@moveonvillain10803 ай бұрын
@@KinoPM2 Hire me 😅
@sergiobenitez14683 ай бұрын
this playlist is a goldmine
@SoftwareDeveloperDiaries3 ай бұрын
Thanks mate!
@samworldpk22 күн бұрын
using this in production with AWS LB and 2 ec2 instances of 4cores and the results are extremely impressive, now downtimes or performance issues in past 5 years.
@AlexanderWunschik3 ай бұрын
This is super exciting and promising. Thanks for the excellent introduction!
@AbdulHannan-or8ql8 ай бұрын
Hi! Your approach by identifying a problem and then solving it is blazingly great 😃 But please make a video on Difference between Cluster and Multi threads? As both utilizing all cpu cores I am looking forward to hear from you
@kooshaforoughi87785 ай бұрын
Man i love your videos, you're a very good teacher, you teach advanced topics clearly and with ease. thank you for teaching me! keep going!
@SoftwareDeveloperDiaries5 ай бұрын
Glad to hear that! 🤓
@vardaanaashish67533 ай бұрын
This was wonderfully explained!
@maximus4510 Жыл бұрын
GOSH, I love this channel! And how your deliver the concept clearly and precisely. Thanks!!
@SoftwareDeveloperDiaries Жыл бұрын
Super happy to hear that you enjoy the content, my friend! ☺
@MelroyvandenBerg Жыл бұрын
Keep in mind cluster is not core-pinning.. It just run on whatever core/thread it would like. Also you can still combine the nodejs cluster feature with workers, which in bigger calculations might help to un-block the main thread. Since nodejs is semi-multithreaded by default.
@MelroyvandenBerg Жыл бұрын
also when running this cluster setup you can't share memory, it will just spawn new processes of NodeJS.
@SoftwareDeveloperDiaries Жыл бұрын
Great point!
@AViStudioMoldova5 ай бұрын
Very clean and good explanation! You're good! Keep going! Thanks!
@chafroudiyed9301 Жыл бұрын
it is the best video of advanced nodejs i ever seen , keep going
@SoftwareDeveloperDiaries Жыл бұрын
Will do, my friend!
@Ad9911io Жыл бұрын
My team lead explained me about clustering a few times and i didn't get shit, it sounded like a super complex thing when he talked about it. Your explanation was super easy to understand!! Thanks alot!
@SoftwareDeveloperDiaries Жыл бұрын
Really happy to hear that! Keep it up mate!
@renzcarlosalanga6077 Жыл бұрын
why? clustering means exactly what it means in the dictionary LOL what's hard about that
@Ad9911io Жыл бұрын
@@renzcarlosalanga6077 So what you're doing here? Just check the dictionary.
@deepakkewalramani08Ай бұрын
Great explained 👏
@lautarogabrielgonzalezscho11773 ай бұрын
Amazing information, thanks for sharing!
@mowmiadrian8608 Жыл бұрын
Bro, I love it when I find a gem like this. Thank you, I was looking for a quality this channel has to offer for very long time. I'm definitely going to subscribe!
@SoftwareDeveloperDiaries Жыл бұрын
Thanks for joining the channel, my friend! Happy to hear you like it! :)
@bryannsi3 ай бұрын
amazing video, and very well explanation
@wasankds7779 ай бұрын
Thanks a lot, This is what I looking for.
@SoftwareDeveloperDiaries9 ай бұрын
Glad I could help!
@hashcode019 ай бұрын
Thank you for the clear explanation. One thing to note is that a single instance still utilizes multithreading for asynchronous operations with libuv. Cluster is advantageous for synchronous operations, as shown in your example.
@anton1492 Жыл бұрын
your videos are awesome man! i usually don't write comments but your channel is so undersubscribed!
@SoftwareDeveloperDiaries Жыл бұрын
I appreciate that, my friend :)
@PaweGradziel Жыл бұрын
Looks really great! Thanks for the video!
@SoftwareDeveloperDiaries Жыл бұрын
Thanks mate! 😉
@DudnikAndrey Жыл бұрын
Thank you! Very clear explanation
@SoftwareDeveloperDiaries Жыл бұрын
Always welcome!
@lexNwimue Жыл бұрын
Great content man. Great channel
@SoftwareDeveloperDiaries Жыл бұрын
Thanks mate!
@shinmini99 Жыл бұрын
omg, bless you.
@aliadel1723Ай бұрын
can you talk about batch processing in nodejs
@enogratechnologies18969 ай бұрын
Great video
@ranadenish5 ай бұрын
Can we use cluster module for "SMPP Protocol" faster performance? SMPP is stateful connections, so I am not getting the full output using cluster, any hint?
@mrlectus7 ай бұрын
What is the difference between loadtest vs ab (apache bench) when i use loadtest The total errors was 500+ but with ab i didn't get any errors and i passed in the same metric as you did. This was an on code without cluster
@tryzack5 ай бұрын
hi, i have a problem here, I've done everything like in the video but the workers wont work? the loadtest was arguably the same as the first time, so to check by myself i made another route without any load to check if i could make a get from that one while the heavy one was still loading and the answer was no, it waits for heavy get to complete before actually doing the main get, its like everything was going to the same worker instead of trying to use different workers, i have 12 cores so it should work...
@saurabhtalele15377 ай бұрын
Thanks nice.... I just want to ask in one core there are multiple processes....or processes is equal to core. ??? Thanks
@SoftwareDeveloperDiaries6 ай бұрын
By default - no, everything will run on a single core. But with the cluster mode - yes.
@labidyramzi4840 Жыл бұрын
Question: Can we achieve Node app horizontal scalability(running node on multiple CPU) with only docker and kuburnetes ?
@SoftwareDeveloperDiaries Жыл бұрын
In theory yes, but I wouldn't suggest combining them. If your application is relatively simple and you prioritize simplicity, Node.js cluster mode may be suitable. If you need advanced orchestration, infrastructure flexibility, and are planning for future growth, Kubernetes might be the better option. Ultimately, the decision depends on your specific use case, requirements, and the resources available to your team.
@fendipratama4792 Жыл бұрын
thank you for your sharing master, I have a question 'if I have 3 servers, running index.js from each server, how to execute index.js from different server?' any response will be highly appreciated
@KaleesM-tm4lw2 ай бұрын
That's why he said once you start your node server by running the node index.js. the node master will distribute the request across multiple instances which you've already spawned... So NVM about which server you wanna to run...
@prokhorov_sergey_igorevich Жыл бұрын
If we have 8 cpu, the primary script use 1 cpu and remain 7 for the application? Conclusion, if we have 2 cpu - it's doesn't work?
@code_react Жыл бұрын
Ok this is very awesome. I have been watching all of other videos on your channel and trust me your videos convinced me to subscribe to your channel. I can't wait to see more topics like this. And many many thanks for taking your time to make these videos.
@SoftwareDeveloperDiaries Жыл бұрын
Thanks for such nice words, my friend!
@KinoPM24 ай бұрын
Any way to not reconnect to MongoDB in each cluster ?
@sanjayms-so9wq6 ай бұрын
helpful
@ArshRadhanpura2 ай бұрын
does it make sense to use this with docker and kubernetes?
@oliverhsu94652 ай бұрын
With containerization, you just add more replicas.
@carlosflores4179 Жыл бұрын
How does pm2 know that it should run in cluster mode instead of fork mode?
@SoftwareDeveloperDiaries Жыл бұрын
PM2 uses a configuration file called "ecosystem.config.js" (or "pm2.config.js") to specify exactly that
@vaibhavm1986 Жыл бұрын
Hi , Thanks I am looking something similar , just want to understand , making clustering this way , or having replica instances via docker , is there any difference between or better as compared to other what is the recommended way ?
@SoftwareDeveloperDiaries Жыл бұрын
That’s a great question. In theory both approaches allow the so called “horizontal scaling”. When going with Node.js clusters, you’re limited to one machine your cluster is running on. So it’s not optimal for complex apps with very heavy loads, since this machine will be the single point of failure. Node.js cluster is a good idea if you have obvious parallel processing scenarios. However, if you have a complex application that requires multiple machines deployed across multiple environments for example, then Docker can be a better choice. At the end of the day, you can actually try combining them. Run a Node.js cluser on multiple Docker instances.
@vaibhavm1986 Жыл бұрын
Thanks 🙂
@HelloWorld-ow1dh7 ай бұрын
i'm getting about ~250 errors even after use of cluster , before it was around ~600, how are you achieving 0 ?
@internetexplorer78805 ай бұрын
Wait i thought pm2 spawns only 1 if you use that command
@aka.theos. Жыл бұрын
Is there any reason why to use this instead of docker and a load balancer ?
@SoftwareDeveloperDiaries Жыл бұрын
Great question. I would use Node.js "cluster" mode when you have a simple application on a single server and want to scale it horizontally across CPU cores for improved performance. But choose Kubernetes with Docker and Load Balancing when dealing with complex, distributed applications that require container orchestration, horizontal scaling across multiple servers, and advanced features like automatic scaling, rolling updates, and service discovery. It's well-suited for cloud-native architectures.
@aka.theos. Жыл бұрын
@@SoftwareDeveloperDiaries Your content is really good I hope you continue to cover advanced topics because not many channels cover them in details like you do
@roonywalsh818310 ай бұрын
@@SoftwareDeveloperDiaries would making a Nodejs cluster in each docker instance be a good idea. Wouldn't it lead to optimization of each server's usage
@DmitryHolubev Жыл бұрын
Hey! What service do you use to create such a good diagrams?
@SoftwareDeveloperDiaries Жыл бұрын
Excalidraw :)
@TuanPham-ph6lr10 ай бұрын
Execuse me, I am new with Nodejs so I have a question, the cpu count is the cpu of the server or cpu of user's computer ? Hope you response me soon.
@SoftwareDeveloperDiaries10 ай бұрын
Hello there! The answer is: the CPU count on the machine that the Node.js app is running on. You’ll be most likely deploying it on the server at the end of the day, so it’s the one that really counts.
@hakanangin Жыл бұрын
Hi, thanks you explanation. I take an error when runing loadtest. What is problem? Error is = node:events:491 throw er; // Unhandled 'error' event ^ Error: read ENOTCONN
@SoftwareDeveloperDiaries Жыл бұрын
Is there anything else that the error message says? Have you made sure that in package.json you "type": "module" like in the video? I've googled the error and it seems like it's mostly caused by another process running on the same port.
@mjprakash1780 Жыл бұрын
@@SoftwareDeveloperDiaries facing same issue
@korkut31 Жыл бұрын
neden 2 Turk inglizce laf edersiniz, danisirsiniz ? neyse. node 16.19.1 versiyonu ile hata vermiyor. node 18.15.0 ile bende hata aldim .
@storylineteam Жыл бұрын
Run the loadtest command in a new terminal window outside of vscode
@qureshiowais6951 Жыл бұрын
How Do we make rest API with cluster?
@SoftwareDeveloperDiaries Жыл бұрын
Same way you would make an ordinary Node.js API with Express, but in this case the entrypoint is primary.js, meaning it opens the port and serves the application.
@qureshiowais6951 Жыл бұрын
@@SoftwareDeveloperDiaries please create few video with lates teach and practice thanks
@mateuszfijak5293 Жыл бұрын
how can I use __dirname in typescript?
@themaridv20005 ай бұрын
It comes by default
@marwanFX483 Жыл бұрын
does this create race condition problem ?
@SoftwareDeveloperDiaries Жыл бұрын
Totally. It all depends on the use case and code that you've written.
@cloudpg07888 ай бұрын
what does this even mean ???
@internetexplorer78805 ай бұрын
Scenario: You go out for dinner in a new restaurant. 1st case: There's only one cook, so if the cook is busy making food for someone else you have to wait a long time for your order 2nd case: There are now multiple cooks, so if other people's food takes time, yours won't