简体   繁体   English

将一个请求“拆分”到多个服务器

[英]“Split” one request to multiple servers

Is it possible to split a request to multiple endpoint servers ? 是否可以将请求拆分为多个端点服务器?

So for example: If server A receives one request it will then forward it to 3 different servers (B,C and D) which will receive that original request with X-Forwarded-For header. 例如:如果服务器A接收到一个请求,它将转发给3个不同的服务器(B,C和D),这些服务器将接收带有X-Forwarded-For标头的原始请求。

              forward
request => A ========> B  
             ========> C
             ========> D

The response for that matter can be a simple 200 OK. 对此事的回答可以简单200 OK。

I have played around with HAProxy and Apache's mode_proxy so far with no success. 到目前为止,我已经使用过HAProxy和Apache的mode_proxy而没有成功。

Also read about HTTP Pipelining but I don't think this is the case here. 另请阅读有关HTTP Pipelining的信息,但我认为这不是这种情况。

Gor was written to do exactly this. 戈尔写的就是这样做的。

Hat tip to Arthur Lutz for posting the answer here . Arthur Lutz提示,在这里发布答案。

Hm. 嗯。 How would I do that? 我该怎么办? Most networking setups, wether they are doing a proxy request or load balancing will retain a one-to-one relationship between the incoming request and the final destination for that specific request. 大多数网络设置,无论是执行代理请求还是负载平衡,都会在传入请求与特定请求的最终目标之间保持一对一的关系。 I think you would need some code in between. 我想你需要一些代码。 I think I'd use mod_perl or a custom apache module in C to intercept the request at an early phase and do the multiple routing with sub-requests. 我想我会在C中使用mod_perl或自定义apache模块在早期阶段拦截请求,并使用子请求进行多路由。

Here is a reverse proxy / load balancer that I've written for a similar purpose with Node.js (it is just for fun, not production ready at the moment). 这是一个反向代理/负载均衡器,我为与Node.js类似的目的而编写(它只是为了好玩,而不是现在的生产就绪)。

https://github.com/losnir/ampel https://github.com/losnir/ampel

It is very opinionated, and currently supports: 它非常自以为是,目前支持:

  • GET Using round-robin selection (1:1) GET使用循环选择(1:1)
  • POST Using request splitting. POST使用请求拆分。 There is no concept of "master" and "shadow" -- the first backend that responds is the one that will serve the client request, and then all of the other responses will be discarded. 没有“主”和“影子”的概念 - 响应的第一个后端是将为客户端请求提供服务的后端,然后所有其他响应将被丢弃。

If someone finds it useful then I can improve it to be more flexible. 如果有人发现它有用,那么我可以改进它以使其更灵活。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM