简体   繁体   中英

threading based on system specs

I have a server with 24gb ram, quad core xeons with hyper threading. I need to create a thread pool in my server application. What are the guidelines for max threads for a thread pool, if any?

Thanks

I would generally go for 2x number of CPU cores. This does not give almost any performance hit in case all threads are busy, but makes sure that if some threads do I/O, the CPU has other work to do is not idle.

The only possible answer without more details is: add threads until a resource is exhausted . Find some tools to monitor system resources, and do it experimentally: add more and more threads to your application, while you keep an eye on the monitor.

  • If the jobs are mostly CPU intensive, you will probably use n_cores + 1 threads.

  • If it does IO with latency (say, crawl a website), you will add way more threads.

  • If it uses tons of memory, you will add threads until you use all your 24gb ram.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM