如何找到最合适缓冲区大小,基于当期的服务器上读取或写入数据流 [英] how to find the best suitable buffer size to read or write Stream based on the currect server
问题描述
我在写这将准备写大文件/数据库服务器。
I am writing a server which will ready and write huge files / database.
我已经使用流读写功能很多地方我使用8192缓冲区大小。
I have used Stream read and write functions many places where I am using 8192 as buffer size.
我也读取TCP套接字大的输入。
I am also reading large input from TCP sockets.
我不知道什么是虚拟机所在的服务将被部署的配置。
I don't know what would be the configuration of the VMs where the service will be deployed.
有没有用,我可以决定我的服务器最合适缓冲区大小,内置的功能?
Is there any built in function using which I can determine the best suitable buffer size for my server?
推荐答案
的关键因素是不是应用程序的缓冲区的大小,但套接字发送的大小和接收缓冲区,它必须> =的带宽时延积链接。上面说的任何增加都应产量为零的利益;下的任何减少将成为最理想的带宽可见。应用程序的缓冲区可以发挥作用,降低了系统的电话,但8192通常是相当足够大多数情况下,特别是网络的人玩。
The critical factor is not the size of the application's buffer but the size of the socket send and receive buffers, which must be >= the bandwidth-delay product of the link. Any increase above that should yield zero benefit; any decrease below it will become visible in suboptimal bandwidth. Application buffers have a role to play in reducing system calls but 8192 is normally quite enough for most purposes, especially networking ones.
这篇关于如何找到最合适缓冲区大小,基于当期的服务器上读取或写入数据流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!