Hi coders 👋. I'm curious...who of you knew about this Libuv Thread Pool setting? Cheers 😎
@LawZist3 жыл бұрын
Not enough
@Omer230072 жыл бұрын
WOW
@juraev00563 жыл бұрын
Please keep doing this kind of content. I am tired of beginner stuff already
@BleedingCode3 жыл бұрын
Thanks for the comment. That's definitely my intention for many of my videos to come 👍.
@aminazgol391810 ай бұрын
wonderful, very clean easy, and well-structured explanation. thank you sir
@BleedingCode9 ай бұрын
Glad it was helpful :)
@grijjly6091 Жыл бұрын
i wanna say something here, if your server doing io things instead high cpu jobs, you can set threadpool size something 256-512-1024, its because reading or writing file is blocking operation and not cpu insentetive which mean , you can handle more client but context change overhead which is ignorable for file operations
@reanibutani95553 жыл бұрын
I do have enjoyed the video, thank you!!! I am just starting in the nodejs path, and this video is really helpful
@BleedingCode3 жыл бұрын
Thank you Rea. Glad you enjoyed it 👍👍
@DR-ee4wv2 жыл бұрын
just got subscribed for this video ❤️❤️❤️❤️❤️
@BleedingCode2 жыл бұрын
Thank you very much 🙏
@kid_kulafu_17274 жыл бұрын
I subscribed in a heartbeat.
@BleedingCode4 жыл бұрын
Many thanks Raphael 🙏
@AkshayJaiswal2 жыл бұрын
This is exactly i was looking for. Thank you so much this turorial was very helpfull.
@BleedingCode2 жыл бұрын
You're very welcome :)
@AkshayJaiswal2 жыл бұрын
@@BleedingCode I had one question. If i use web worker in my node project will that effect thread pool?
@BleedingCode2 жыл бұрын
@@AkshayJaiswal It shouldn't. The Libuv Threadpool manages async IO tasks, where Worker Threads and, to my understanding, web workers, focus on userland code (i.e. your actual JS logic)
@jovert24454 жыл бұрын
You deserve more subscribers, keep it up 🍻
@BleedingCode4 жыл бұрын
Thank you Jovert for this awesome comment 🙏
@arunavachakraborty55573 жыл бұрын
Brilliant ! Subscribed ! Keep going ! :)
@BleedingCode3 жыл бұрын
Thank you 🙏
@snoblik699 ай бұрын
Hi, very well explained, thank you! I have a question about the v8-pool-size=num parameter. When it is good to increase the value of UV_THREADPOOL_SIZE according to the number of logical cores, what value should the parameter V8-POOL-SIZE be? Thanks in advance for the recommendation. I can't find a relevant, factually supported comment on this anywhere on the internet.
@markmiller85713 жыл бұрын
Wow, that is amazing information and a great tutorial! Thanks so much!!
@BleedingCode3 жыл бұрын
Glad you enjoyed it 👏
@matthew78uk2 жыл бұрын
Hi John, probably a silly question: you mentioned that increasing the thread pool size above the number of the logical CPU would not improve the results in the benchmark, but could it make it worse? If not wouldn't it make sense to just set the thread pool to 1024 so that all the logical cpus would be used by default?
@BleedingCode2 жыл бұрын
Hi Matteo. Great question. The problem is that NodeJS will create 1024 threads, which will then be shared between all logical CPUs. It doesn't make sense, but it's what will happen. This is will have a negative effect on the logical CPUs.
@ahlambeyoud17093 жыл бұрын
Thank you very much, very clear explanation great content, I hope you make a video about query optimization as well :)
@BleedingCode3 жыл бұрын
Thank you very much Julia. Regarding Query Optimization, are you referring to MongoDB queries, or something else? Cheers
@ahlambeyoud17093 жыл бұрын
MongoDB :)
@BleedingCode3 жыл бұрын
@@ahlambeyoud1709 Awesome. I’ve got some great stuff for Mongo. Need to get 2 more videos on NodeJS Performance Optimization out the way. I’ll then start diversifying. Stay tuned 😎
@ahlambeyoud17093 жыл бұрын
@@BleedingCode I am very interested in the topic of node optimization as well I am really looking forward to that, I am a bit confused on how to use clusters and redis cashing and pm2 how do we use them all together? can we use them all together? I hope your content will help, I am really looking forward to it :) thank you
@aminazgol391810 ай бұрын
does dynamic configuration work as intended on a docker image?
@BleedingCode9 ай бұрын
Yes it does. I use docker containers for most of my NodeJS Apps 👍.
@AndrosAndWindows3 жыл бұрын
Subscribed Loved the video and also can you please please make a video on how to install Libuv and how to use it in production ?
@BleedingCode3 жыл бұрын
Thank you very much Ramsai. Tell me, do you mean installing libuv by itself? Because it comes with NodeJS. It doesn't need to be installed separately unless you want to develop apps outside the scope of NodeJS but using libuv.
@AndrosAndWindows3 жыл бұрын
@@BleedingCode Thanks you so much I don't know it comes with Nodejs . So now I can use Libuv in nodejs itself how you instructed in the video ?
@LawZist3 жыл бұрын
This is really really good stuff!
@BleedingCode3 жыл бұрын
Many thanks 👍
@inclinedscorpio2 жыл бұрын
Hi There! Thanks for this video, I have a doubt! I want to use the dynamic way of using multithreading- I have dockerised my application- handled by Kubernetes, currently using VM's to manage the K8 node. Do you see any potential problem which could occur due to using dynamic way? I couldn't understand how to give it through env or CMD as using software on different VM and different Machine will require to understand core everytime so I was hoping to use the dynamic way! Your thoughts? :)
@BleedingCode2 жыл бұрын
Hi there. Thanks for the feedback. There are no problems using the dynamic way. I also use Docker and deploy to k8s clusters. The most important is that the ENV is set as early as possible and not changed again 👍
@inclinedscorpio2 жыл бұрын
@@BleedingCode Thanks ❤️
@aliarslanansari3 жыл бұрын
Amazing tutorial 🤩
@BleedingCode3 жыл бұрын
Thank you Ali. I really appreciate it 👍
@blameItleaveit3 жыл бұрын
If you provide all of your availabile threads to nodejs, what about other proces that requires thread? Generally there are multiple process running which are hungry for threads.
@BleedingCode3 жыл бұрын
Hi Dev. Thanks for commenting. Are you referring to other Node JS processes or just any process running on the VM or machine? Running of your Node app and the threads that are created happens automatically and is scheduled by the OS. It's still preferred to have access to all CPUs instead of just one, even if the other CPUs are busy. Remember it's the main thread we want to primarily keep active and performant.
@ashutoshtiwari42582 жыл бұрын
Hi There ! Thanks for the video 🤟🏼 I have a doubt. In my Nodejs application (connected to DB) .... Requests is processed and returned within 100ms but in UI it shows it took 600ms - 1.5sec, what can be the reason for this ? I am getting around 100 requests per second apart from that request... Is there any way I can debug it?
@BleedingCode2 жыл бұрын
Hi there. You're very welcome for the video. Regarding the UI response being different, is it not including the download time of the response data? Postman is a great tool to check exactly where the time is going in the real world.
@all_top_5_features3 жыл бұрын
Will pm2 do the same stuff?
@BleedingCode3 жыл бұрын
Hi Anuj. Sorry for the late reply. Honestly I'm not too sure, because PM2 manages multiple instances of your Node application using either clustering or child processes. So in theory your primary Node instance is where you declare the libuv Threadpool size. Sorry, I don't use PM2 that much as I primarily run my apps in Kubernetes.
@MrBrainStarX3 жыл бұрын
Hey man, first of all thx for the video. I have a question about that topic: I am currently using the cluster module for running a processes on each cpu(in paralell), can I still use the thread pool management in addition ?
@BleedingCode3 жыл бұрын
You are very welcome. Yes you can still use thread-pool management and manage how many threads will spawn instead of the default 4. However, these will be duplicated per process, because child processes or clustering (which uses child processes), does not share memory, hence it will be difficult for one libuv threadpool to interact with multiple node processes. Make sense?
@MrBrainStarX3 жыл бұрын
@@BleedingCode I do understand, thank you very much.
@sakshamsrivastava62803 жыл бұрын
@@MrBrainStarX Hey, can you please help me out with the explaination if you understood ? should we use it with it or not
@MrBrainStarX3 жыл бұрын
@@sakshamsrivastava6280 Hey, it's up to you. But you can use it without a problem, at least I got no errors. So you can run multiple threads per process.
@TheSiddhaartha3 жыл бұрын
If I have to do simple writes to a NoSQL DB like Cassandra/MongoDB, then is Node js faster than Java? The number of requests per second are around 1.4 million. Thanks!
@BleedingCode3 жыл бұрын
Hi Siddharth. Thanks for the comment. Unfortunately this is not a simple answer and depends greatly on infrastructure, optimization of the statements/queries, size of the tables/collections and indexes, and a number of other factors 😳
@TheSiddhaartha3 жыл бұрын
@@BleedingCode do you think I can start with node js? I am not using nosql anymore as it's relational data. So going to decide on AWS Kinesis or similar solution.
@BleedingCode3 жыл бұрын
@@TheSiddhaartha Yes you can absolutely. NodeJS is powerful enough to do the job, but again...many many factors at play :)
@uditsoni242 жыл бұрын
Hi John, I have implemented Nodejs clustering logic in my application. in my machine there are 16 Logical cores, 8 physical cores, that means there will be 16 servers of my application, what would be the best, in this case, should I set thread pool size to 1 or 16? If we set it to 16 it's then each node server will have 16 thread pool size as I am having 16 servers and each server will have 16 thread pool size so there are gonna be 256 threads. As you said it should be equal to the Logical CPU, Could you please tell me what should be the number of thread pool if there is clustering implemented?
@BleedingCode2 жыл бұрын
Hi Udit. Great question and you are absolutely right. Because you are running 16 nodejs runtimes, it's going to count to 256 threadpools, which won't make any sense. Have you seen my video on managing multiple threads using 1 runtime? Is this an option for you?
@habutf Жыл бұрын
Pretty sur @BleedingCodes CPU also has more logical cores than he states in the video.
@habutf Жыл бұрын
Ah... it comes a minute later...
@rage1282 жыл бұрын
i download your code exacly but there is no effect on avarage request count by changing UV_THREADPOOL_SIZE ; what im doing wrong ?
@BleedingCode2 жыл бұрын
Hmm. Seems to be the same issue to what you're having with the worker threads? Again, can you confirm your machine specs?
@Dev_pig2 жыл бұрын
What if i run the application on k8s as a container?
@BleedingCode2 жыл бұрын
It will work just fine. Remember, the container runs against the underlying resources that have been assigned to K8S.
@Dev_pig2 жыл бұрын
@@BleedingCode thanks, however on k8s we have min cpu and max cpu config. For example, min cpu 1 core, max cpu 6 core, then what is the os.cpu.length ..
@BleedingCode2 жыл бұрын
@@Dev_pig Hi there. I can't really answer that off the bat, but could you not add a console.log to your app to see what it's returning in terms of logical CPUs?
@Dev_pig2 жыл бұрын
@@BleedingCode I found the answer. on k8s container, min cpu (requests.cpu) is used for choosing right node, and max cpu (limits.cpu) is what the application uses. So, if I use 8 as limits.cpu config, then application can use 8 cores from the beginning Thank u for letting me know many things :)
@BleedingCode2 жыл бұрын
@@Dev_pig Brilliant...good catch 👏
@lakshmankashyap46903 жыл бұрын
If I using pm2 on server so is it necessary to implement workthread in high performance task in nodejs
@BleedingCode3 жыл бұрын
Hi there. It depends on how you've set up clustering using PM2. If you already have clustering running for your runtime, then leave it be.
@lakshmankashyap46903 жыл бұрын
@@BleedingCode thanks i think I found with the help of your video after testing with autocannon and work pool then realize if pm2 start -i max then cluster run so worker-poll and pm2cluster , nodejs with cluster master salve are same right?
@BleedingCode3 жыл бұрын
@@lakshmankashyap4690 Cluster and Child Processes are actually the same...cluster just uses child processes differently. WorkerPool is different, as it uses Worker Threads and doesn't spawn child processes. This is what makes Worker Threads awesome.
@ngneerin3 жыл бұрын
Font size too small
@BleedingCode2 жыл бұрын
Sorry about that. Didn't realize it at the time, but my future videos will support mobile much better, which will resolve the font size 👍