开发者

How do I determine total number of child threads?

I am working on a linux server programming and I am not sure the proper number of child threads for my thread pool. These threads are doing the actual work including parsing and data processing and more. If my server has 8 cores then what is the proper number of child threads that I should spawn? Thanks i开发者_StackOverflow中文版n advance..


If you question is about how many threads you actually have, then man ps will give you a number of options for showing the running threads as they were processes -- all you need to do is count them.

If your question is about how many threads you should create, then that entirely depends on your application and what is does. If every thread is free of IO and and syncronouz calls, and all it does is number crunching -- then you should probably have no more than 8 threads (one for each core). However if your application is performing anything which would cause it to wait for external IO, then you could benefit from more. And I say could as it entirely depends on how your application is build -- in most cases you would need to experiment; which typically would be done by testing first with 8 threads and see how many requests per second you can handle, and then increase the number of threads and run the experiment again. Then plot the results as a curve and find the sweet spot where extra threads add no (or little) additional value -- and that would be the thread count you should configure. This is of-cause assuming that you are not causing other bottle necks such as memory / swapping, which you would want to avoid

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜