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

查看:30
本文介绍了与 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.

两个代理套接字上的发送和接收窗口大小设置为 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天全站免登陆