WCF 在连接到 SQL Azure 时禁用 UseNagleAlgorithm
在 Azure 上托管一组访问 SQL Azure 数据库的 WCF REST 服务。我看到 ServicePointManager.UseNagleAlgorithm 设置为 true。我知道将其设置为 false 会加快对表存储的调用(插入记录 < 1460 字节) - 以下 链接 讨论了它。
我的问题 - 禁用 Nagle 算法是否也会加快对 SQL Azure 的调用速度?
Have a bunch of WCF REST services hosted on Azure that access a SQL Azure database. I see that ServicePointManager.UseNagleAlgorithm is set to true. I understand that setting this to false would speed up calls (inserts of records < 1460 bytes) to table storage - the following link talks about it.
My Question - Would disabling the Nagle Algorithm also speed up my calls to SQL Azure?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Nagle 的算法主要是将 TCP 级数据缓冲到较小的数据包中,并且与记录大小无关。您可以向表存储中写入 1300 字节数据的行,但是一旦包含 TCP 标头信息、内容序列化等,传输的数据可能会大于 1460 字节的阈值。
无论如何:最终结果是,当启用算法时,您可能会看到高达 500 毫秒的写入延迟,因为数据被缓冲,从而导致线路上的 TCP 数据包减少。
禁用 Nagle 的算法可能有助于您访问 SQL Azure,但您可能需要进行一些基准测试,以查看您的吞吐量是否因您正在进行的读/写类型而受到影响。使用必要的 SQL 命令文本调用 SQL Azure 可能会产生足够大的数据包,禁用 nagle 不会产生任何影响。
Nagle's algorithm is all about buffering tcp-level data into a smaller # of packets, and is not tied to record size. You could be writing rows to Table Storage of, say, 1300 bytes of data, but once you include tcp header info, content serialization, etc., the data transmitted could be larger than the threshold of 1460 bytes.
In any case: the net result is that you could be seeing write delays up to 500ms when the algorithm is enabled, as data is buffered, resulting in less tcp packets over the wire.
It's possible that disabling Nagle's algorithm would help with your access to SQL Azure, but you'd probably need to do some benchmarking to see if your throughput is being affected based on the type of reads/writes you're doing. It's possible that the calls to SQL Azure, with the requisite SQL command text, result in large-enough packets that disabling nagle wouldn't make a difference.