与Windows上用于本地主机IPC的命名管道相比,TCP套接字的速度有多慢? [英] How slow are TCP sockets compared to named pipes on Windows for localhost IPC?

查看:400
本文介绍了与Windows上用于本地主机IPC的命名管道相比,TCP套接字的速度有多慢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个放置在TCP服务之前的TCP代理,该服务应该处理来自野生Internet的500到1000个活动连接.

I am developing a TCP Proxy to be put in front of a TCP service that should handle between 500 and 1000 active connections from the wild Internet.

代理与服务在同一台计算机上运行,​​并且大部分是透明的.该服务在很大程度上不知道代理,唯一的例外是客户端的真实远程IP地址的通知.

The proxy is running on the same machine as the service, and is mostly-transparent. The service is for the most part unaware of the proxy, the only exception being the notification of the real remote IP address of the clients.

这意味着,对于每个入站打开的TCP套接字,服务器上还有两个套接字:代理中的对的第二个套接字,以及代理后面的真实服务中的一个套接字.

This means that, for every inbound open TCP socket, there are two more sockets on the server: the secondth of the pair in the Proxy, and the one on the real service behind the proxy.

两个Proxy套接字上的send和recv窗口大小设置为1024字节.

The send and recv window sizes on the two Proxy sockets are set to 1024 bytes.

对此有何性能影响?此配置有多慢?我是否应该在更改服务以使用命名管道(或其他IPC机制)上付出一些努力,或者在大多数情况下localhost TCP套接字是一种有效的IPC?

What are the performance implications on this? How slow is this configuration? Should I put some effort on changing the service to use Named Pipes (or other IPC mechanism), or a localhost TCP socket is for the most part an efficient IPC?

两个应用程序合并不是一个选择.现在,我们只停留在这两个过程的配置上.

The merge of the two apps is not an option. Right now we are stuck with the two process configuration.

编辑:在同一硬件上进行两个单独的处理的原因是100%经济.我们只有一台服务器,并且我们不打算获得更多(没有钱).

EDIT: The reason for having two separate process on the same hardware is 100% economics. We have one server only, and we are not planning on getting more (no money).

TCP服务是Visual Basic 6中的遗留软件,其增长超出了我们的预期.代理是C ++.我们没有时间,金钱和人力来重写VB6代码并将其迁移到现代编程环境中.

The TCP service is a legacy software in Visual Basic 6 which grew beyond our expectations. The proxy is C++. We don't have the time, money nor manpower to rewrite and migrate the VB6 code to a modern programming environment.

代理是我们为缓解服务上特定性能问题的一种尝试,即 DDoS攻击不时得到.

The proxy is our attempt to mitigate a specific performance issue on the service, a DDoS attack we are getting from time to time.

代理是开源的,这是项目源代码.

推荐答案

它将是相同的(或至少没有可测量的不同). Winsock足够聪明,可以知道它是否正在与同一主机上的套接字通信,在这种情况下,它将使IP之下的几乎所有内容短路,并直接将数据复制到缓冲区.在命名管道与套接字方面,如果将来可能需要与其他计算机进行通信,请选择套接字.如果您知道自己永远不需要这样做,请选择开发人员最熟悉或最熟悉的开发人员.

It will be the same (or at least not measurably different). Winsock is smart enough to know if it's talking to a socket on the same host and, in that case, it will short-circuit pretty much everything below IP and copy data directly buffer-to-buffer. In terms of named pipes vs. sockets, if you need to potentially be able to communicate to different machines ever in the future, choose sockets. If you know for a fact that you'll never need to do that, pick whichever one your developers are most familiar or most comfortable with.

这篇关于与Windows上用于本地主机IPC的命名管道相比,TCP套接字的速度有多慢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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