(如何)我可以减少插座延迟? [英] (How) Can I reduce socket latency?

查看:97
本文介绍了(如何)我可以减少插座延迟?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了做一些东西,这里是不相关的HTTP代理,但它是由一个巨大的数额(600us它没有代理VS 60000us)增加了客户的时间到服务。我想我已经发现那里的那段时间大部分是来自 - 我的代理发送完回客户端和客户端精加工获得者之间。现在,服务器,代理服务器和客户端在同一主机上运行,​​使用localhost作为地址。

I have written an HTTP proxy that does some stuff that's not relevant here, but it is increasing the client's time-to-serve by a huge amount (600us without proxy vs 60000us with it). I think I have found where the bulk of that time is coming from - between my proxy finishing sending back to the client and the client finishing receiving it. For now, server, proxy and client are running on the same host, using localhost as the addresses.

一旦代理完成发送(一旦它从发送()至少返回),我打印的gettimeofday的赋予绝对时间的结果。当我的客户已经收到,它打印的gettimeofday的结果。因为他们都在同一台主机上,这应该是准确的。所有send()调用与任何标志,所以他们阻止。两者之间的差大约是40000us

Once the proxy has finished sending (once it has returned from send() at least), I print the result of gettimeofday which gives an absolute time. When my client has received, it prints the result of gettimeofday. Since they're both on the same host, this should be accurate. All send() calls are with no flags, so they are blocking. The difference between the two is about 40000us.

在其上侦听客户端连接代理的插座设置与提示AF_UNSPEC,SOCK_STREAM和AI_PASSIVE。 presumably接受来自(插槽)ING上,将有相同的参数?

The proxy's socket on which it listens for client connections is set up with the hints AF_UNSPEC, SOCK_STREAM and AI_PASSIVE. Presumably a socket from accept()ing on that will have the same parameters?

如果我正确理解这一切,阿帕奇设法做600us的一切(包括任何原因造成这种40000us延迟当量)。任何人都可以提出什么可能导致此?我已经试过设置TCP_NODELAY选项(我知道我不应该,它只是看它是否发挥了作用),并完成发送和整理接收了降权,我忘了号码,但℃之间的延迟。1000US

If I'm understanding all this correctly, Apache manages to do everything in 600us (including the equivalent of whatever is causing this 40000us delay). Can anybody suggest what might be causing this? I have tried setting the TCP_NODELAY option (I know I shouldn't, it's just to see if it made a difference) and the delay between finishing sending and finishing receiving went right down, I forget the number but <1000us.

这是所有在Ubuntu Linux 2.6.31-19。感谢您的帮助。

This is all on Ubuntu Linux 2.6.31-19. Thanks for any help

推荐答案

您真的不能做有意义的性能测试上与客户,代理和源服务器在同一台主机上的代理。

You can't really do meaningful performance measurements on a proxy with the client, proxy and origin server on the same host.

将它们都放置在一个网络上的不同主机。使用真实的硬件设备为他们所有,或专门的硬件测试系统(例如思博伦)。

Place them all on different hosts on a network. Use real hardware machines for them all, or specialised hardware test systems (e.g. Spirent).

您的方法是没有意义的。任何人都没有延迟,在实践中他们的原始服务器的600us反正。运行在同一台主机上的所有任务,创建争和全unreaslistic网络环境。

Your methodology makes no sense. Nobody has 600us of latency to their origin server in practice anyway. Running all the tasks on the same host creates contention and a wholly unreaslistic network environment.

这篇关于(如何)我可以减少插座延迟?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆