All you need to know about "child_process" in Node.js

  Рет қаралды 4,875

Software Developer Diaries

Software Developer Diaries

3 ай бұрын

Child Process module in Node.js lets you spin up new isolated processes, which can help you in many ways. It is similar to Worker Threads in its usage but there is a big difference in its purpose. Let's learn all of that!
======⚡⚡⚡======
The blackboard in the video: eraser.io
☕ Buy me a coffee: www.buymeacoffee.com/software...
🙌 Become my Patreon and get exclusive perks: / softdevdiaries
💼 Follow me on LinkedIn and drop me a message if you'd like: / gadirovgs
💻 Also, let's connect on GitHub: github.com/gusgad
📚 Resources:
Official docs: nodejs.org/api/child_process....
Code: github.com/gusgad/youtube-tut...
And don't forget to subscribe for more videos like this 😊

Пікірлер: 15
@ofeklevy1242
@ofeklevy1242 3 ай бұрын
One of the best channels for learning advanced node-js and backend related stuff. BTW im waiting for the best practices for security in web apps. :)
@hanibal43
@hanibal43 3 ай бұрын
These are amazing videos! no one is doing deep dives in node.js love the video would like to see more practical uses of these like with small API project videos
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries 3 ай бұрын
Thanks mate! I'll keep posting more of these then 😉
@alphonsoacqua
@alphonsoacqua 2 ай бұрын
Outstanding! Finally someone is making quality videos about advanced Node.js. Thank you. 🤝
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries 2 ай бұрын
Thanks mate 😊!
@yousafraza9347
@yousafraza9347 Ай бұрын
Really love this methodology of deep diving a specific topic. Glad I found this channel
@stonebaydevil2839
@stonebaydevil2839 3 ай бұрын
Excellent video!
@user-ig3io2ol1c
@user-ig3io2ol1c 3 ай бұрын
I love your content man
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries 3 ай бұрын
Happy to hear! 🫶
@vlatkod1065
@vlatkod1065 2 ай бұрын
good job man!
@headlights-go-up
@headlights-go-up 3 ай бұрын
love these types of videos! so much better than the superficial "build a twitter clone" videos that everyone else makes.
@rahul455roy
@rahul455roy 3 ай бұрын
Please also create video on middleware best practices
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries 3 ай бұрын
Will do!
@LuisGutierrez-ct6iw
@LuisGutierrez-ct6iw 3 ай бұрын
Nice video man, but I still feel curious about what is the main difference using this approach rather than NodeJS cluster mode, I mean what are the special scenarios where is useful to use either worker_threads, cluster mode with NodeJS or PM2 and child processes, is it also recommended to use all of them in the same app? Thank you in advance
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries 3 ай бұрын
Hey mate! Thanks for watching the video and for your thoughtful question! When it comes to handling concurrency in Node.js, there are indeed several options like child processes, Node.js cluster mode, and tools like PM2. Each has its own strengths and best-fit scenarios. Child processes: These are great when you need to run separate tasks concurrently, like handling CPU-intensive operations or interacting with external processes. Imagine you're building a web server with Node.js, and you need to generate PDF reports on the fly in response to user requests. However, generating PDFs is a CPU-intensive task that could block the event loop. Here, you could offload the PDF generation to a child process, allowing your main server to continue handling incoming requests without being blocked. Node.js cluster mode: This is specifically designed for scaling your Node.js application across multiple CPU cores. It's ideal for network-bound applications where you want to take advantage of parallelism to handle multiple requests simultaneously. Suppose you're developing a chat application where multiple users can connect simultaneously. Each incoming connection triggers some processing on the server, such as authentication and message handling. By using cluster mode, you can spawn multiple instances of your application across CPU cores, allowing you to handle more concurrent connections efficiently. PM2: PM2 is more of a process manager that helps in running and managing Node.js applications in production environments. It can handle clustering, monitoring, and auto-restarting of processes, making it convenient for deployment scenarios. Let's say you have a production-grade API serving hundreds of requests per minute. You want to ensure high availability and automatic restarts in case of failures. PM2 can manage your Node.js process, keeping it running smoothly by automatically restarting it if it crashes. Additionally, PM2 can monitor CPU and memory usage, allowing you to scale your application vertically or horizontally as needed. As for whether to use all of them in the same app, it really depends on your specific use case. Generally, you wouldn't use child processes and cluster mode together since they serve similar purposes. However, PM2 can complement either of them by providing additional management features. Hope this was helpful 😊
Mastering Memory Management in Node.js: Tips and Tricks for Better Performance
16:06
Software Developer Diaries
Рет қаралды 30 М.
6 tips for improving Node.js performance #Shorts
1:01
Software Developer Diaries
Рет қаралды 4 М.
1,000 Diamonds! (Funny Minecraft Animation) #shorts #cartoon
00:31
toonz CRAFT
Рет қаралды 38 МЛН
Best KFC Homemade For My Son #cooking #shorts
00:58
BANKII
Рет қаралды 69 МЛН
Node.js "Event Emitters" Explained
9:50
Software Developer Diaries
Рет қаралды 7 М.
We need to talk about this benchmark
42:25
Theo - t3․gg
Рет қаралды 65 М.
Deep Dive into REST API Design and Implementation Best Practices
12:02
Software Developer Diaries
Рет қаралды 43 М.
Node.js Tutorial - 61 - Cluster Module
15:10
Codevolution
Рет қаралды 33 М.
100+ Docker Concepts you Need to Know
8:28
Fireship
Рет қаралды 889 М.
Node.js Security Best Practices: JWT blacklisting, rate limiting, schema validation
12:02
PROOF JavaScript is a Multi-Threaded language
8:21
Beyond Fireship
Рет қаралды 271 М.
Concurrency vs Parallelism in Node.js
7:47
Mehul - Codedamn
Рет қаралды 41 М.
low battery 🪫
0:10
dednahype
Рет қаралды 1,6 МЛН
Копия iPhone с WildBerries
1:00
Wylsacom
Рет қаралды 8 МЛН
📱магазин техники в 2014 vs 2024
0:41
djetics
Рет қаралды 421 М.
$1 vs $100,000 Slow Motion Camera!
0:44
Hafu Go
Рет қаралды 28 МЛН