HTTP 代理 servlet 太慢了

发布于 2024-12-23 11:39:23 字数 556 浏览 1 评论 0原文

我先描述一下我的工作环境。我是一名大学生。我的实验室有四台机器,A、B、C 和 D,通过 1Gb/s 以太网连接。我有一个集群系统,它使用 B 和 C 作为计算从站。这个集群计算系统有一个Python HTTP服务器运行在机器A上。我想将这个Python HTTP服务器公开给校园外的其他人。好消息是我的实验室已经建立了一个在机器 D 上运行的 Jetty 服务器。这个 jetty 服务器可以在校园外访问。所以我在机器 A 上设置了一个 HTTP 代理 servlet。我使用从 http://www 下载的这个代理 servlet .servletsuite.com/servlets/httpproxy.htm。任何发送到此 servlet 的请求都将定向到我的 Python 服务。

现在的问题是我发现代理 servlet 非常慢。通常情况下,B 机(集群计算)的实际处理时间仅为 0.5 秒,但结果需要 5 秒才能响应并显示在我的浏览器上。

这是为什么?有人遇到过 HTTP 代理速度慢的情况吗?

Let me describe my working env first. I am a university students. My lab has four machines, A, B, C and D connected by 1Gb/s Ethernet. I have a clustering system which uses B and C as computing slaves. This clustering computing system has a Python HTTP server running on machine A. I want to expose this Python HTTP server to other people outside of campus. The good thing is my lab has already set up a Jetty server running on machine D. This jetty server can be reached outside of campus. So I set up a HTTP proxy servlet on machine A. I use this one downloaded from http://www.servletsuite.com/servlets/httpproxy.htm. Any request goes to this servlet will be directed to my Python service.

Now, the question is I find the proxy servlet is quite slow. Usually the actual processing time on machine B (clustering computing) is just 0.5 seconds but the result need 5 seconds to be responded and displayed on my browser.

Why is that? Does anybody face slow HTTP proxy situation before?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

生寂 2024-12-30 11:39:23

这看起来相当慢,我的第一个想法是,那个 servlet 在做什么?你有源码吗?

接下来的想法是 Jetty 显然提供了一个 ProxyServlet 他们自己的。也许他们做得更好。也许你应该尝试一下。

That seems pretty slow, and my first thought is, what is that servlet doing? Do you have the source?

Next thought is that Jetty apparently provides a ProxyServlet of their own. Perhaps they did a better job. Maybe you should try that instead.

猥︴琐丶欲为 2024-12-30 11:39:23

你说机器 A 有一个“Python HTTP 服务器”。它是基于 BaseHTTPServer 的处理程序吗?它一次只能处理一个请求:因此请排除任何等待问题

我猜你正在使用同一台服务器来接受来自外部的作业并通过 HTTP 协议将它们委托给 B 和 C。


D 到 A 的路径

  1. 要诊断外部到 D
  2. - 代理 D 转发到 A
  3. A 到 B - A 将工作委托给 B

同步外部计算机、A 和 D 完美(使用 NTP)并记下这些times:

  1. 从 D 的 Jetty 访问日志向D 发出请求之前和之后立即在外部计算机上打印时间
  2. ,记下请求的时间
  3. A 执行完毕后立即打印 A 上的时间 do_get()
  4. 在 A 之后打印 A 上的时间接收来自 B 的结果

Do post #1、#2-#3 和 #3-#4 的延迟,以便更好地诊断延迟发生的位置。

You say that machine A has a "Python HTTP server". Is it a handler based on BaseHTTPServer? It can handle only one request at a time: so do rule out any waiting problems.

I guess you are using the same server both to accept jobs from outside and delegate them to B and C over HTTP protocol.


To diagnose the paths

  1. Outside to D
  2. D to A- the proxy D forwards to A
  3. A to B- A delegates the work to B

Sync the outside computer, A and D perfectly (with NTP) and note these times:

  1. print the time on the outside computer immediately before and after requesting to D
  2. from the Jetty access logs of D, note the time of your request
  3. print the time on A as soon as A preforms do_get()
  4. print the time on A after A receives results from B

Do post the delays from #1, #2-#3 and #3-#4 to better diagnose where the delay occurs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文