简体   繁体   English

如何确定将大量文件复制到外部共享文件夹的并行Java线程的理想数量?

[英]How can I determine the ideal number of parallel java threads for copying a large set of files to an external shared folder?

What should be the ideal number of parallel java threads for copying a large set of files from a quad core linux box to an external shared folder? 将大量文件从四核linux盒复制到外部共享文件夹的并行java线程的理想数目是多少? I can see that with a single thread it is taking a hell lot of time to move the files one by one. 我可以看到,使用单个线程会花费大量时间来逐个移动文件。 Multiple threads is improving the copy performance, but I don't know what should be the exact number of threads. 多线程可以提高复制性能,但是我不知道确切的线程数应该是多少。

I am using Java executor service to create the thread pool. 我正在使用Java执行程序服务来创建线程池。

Just try different variants and measure performance. 只需尝试不同的变体并评估性能。 There are also such bottlenecks as HDD and network speed, so I guess there is no definite answer. HDD和网络速度也存在瓶颈,因此我想没有确切的答案。

Absolutely you should work this out by testing. 绝对应该通过测试来解决这个问题。 As Dmitry points out, there are many factors involved. 正如德米特里(Dmitry)所指出的,涉及许多因素。 In fact, CPU is almost certainly not the bottleneck with an IO- and network-based operation. 实际上,CPU几乎可以肯定不是基于IO和基于网络的操作的瓶颈。 You'll probably find things level off and start to get worse before you have too many threads, but if you want to minimise testing, use a graph of a few results to interpolate a good guess for the ideal value. 在线程过多之前,您可能会发现情况趋于平稳并开始变得更糟,但是如果您想最小化测试,请使用一些结果的图表来插值一个理想值的良好猜测。

To get a better understanding of what's taking all the time, use metrics tools to measure utilisation of your resources - in this case that should include network interface traffic and disk queue length. 为了更好地了解所有时间,请使用指标工具来衡量资源的利用率-在这种情况下,该指标应包括网络接口流量和磁盘队列长度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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