面向服务架构中的网关服务

发布于 2024-11-18 07:55:06 字数 338 浏览 3 评论 0原文

我热衷于实现我自己的单入口“网关”,它可以做两件事。

首先,它记录 SOA 服务器已处理了多少请求,并将下一个请求循环到最可用的服务器。完全控制负载平衡逻辑很有吸引力。

其次,这个“网关”将是我所有服务(包括安全服务)的唯一联络人。如果客户端发送用户名-密码组合,它将它们传递给安全服务,安全服务在成功验证时授予令牌。如果客户端发送令牌,网关将通过安全服务运行该令牌,并且如果符合要求,则将请求传递给其中一项业务服务。隐藏或封装除网关之外的所有服务似乎是可取的。

我的问题是:有什么理由说明这不是“正确的做事方式”?当已经有一个框架可以实现我上面描述的功能时,我是否要重新发明轮子?我的堆栈是.NET 和 WCF。

I'm enamoured with the idea of implementing my own single-entry-point "gateway" that does two things.

First, it records how many requests have been handled by SOA servers and cycles the next request to the most available server. Full control over load balancing logic is attractive.

Second, this "gateway" would be the single liaison to all my services, including security. If the client sends up a username-password combo, it passes them to the security service which grants a token on successful authentication. If the client sends up a token, the gateway runs this token by the security service and, if it's kosher, passes the request to one of the business services. Hiding or encapsulating all services besides the gateway seems desirable.

My questions are: Is there any reason why this would not be "the right way to do things"? Am I reinventing the wheel when there's already a framework that does what I've described above? My stack is .NET and WCF.

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

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

发布评论

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

评论(1

毅然前行 2024-11-25 07:55:06

好问题,但我必须同意 sweetfa 的评论,在 99% 的情况下,现成的负载均衡器将是最好的选择。更详尽的选项列表:

  1. 硬件负载平衡器/网关(例如 IBM XML Gateway) - 非常可扩展且昂贵
  2. 服务总线软件(例如 Oracle Service Bus)也将实现安全性和负载平衡 - 非常可配置且昂贵。 开源负载均衡器软件(例如 Apache HTTPD 代理模块)的可扩展性不如硬件解决方案
  3. ,将拥有大量用户,他们将通过论坛帮助您进行设置。 其配置方式将比基于服务注册表 (UDDI v3) 的选项 1 和 2 负载平衡更复杂
  4. 许多解决方案具有相当高的可扩展性和健壮性,但当服务使用者在每次调用时查找提供者 URI 时, 。注册中心将通过返回不同的 URI 来对请求进行负载平衡。该解决方案不会充当安全网关,
  5. 如果您需要一些高级自适应负载平衡算法或者需要非标准安全层,那么消费者可能会忽略它来构建您自己的解决方案。让我们忘记非标准安全性,这很少是一个好主意,但自适应负载平衡可能是可取的。选项 1-3 将根据响应时间进行循环或加权循环或自适应循环,并且它们将检测无响应的实例。选项 1 和 3 提供了另一个难以实现的功能,即 HTTP 会话粘性,但对于 SOAP 或 REST 服务来说这不是必需的

Good question, but I have to agree with sweetfa's comment, in 99% of cases an off-the-shelf load balancer will be the best option. A more exhaustive list of options:

  1. hardware load balancer/gateway (e.g. IBM XML Gateway) - very scalable and expensive
  2. a service bus software (e.g. Oracle Service Bus) will do the security and load balancing as well - very configurable and expensive. Less scalable than hardware solution
  3. an open source load balancer software (e.g. Apache HTTPD Proxy module) will have large number of users who will help you setting it up via forums. Many of the solutions are pretty scalable and robust, but will have a more complex way of configuration than options 1 and 2
  4. load balancing based on service registry (UDDI v3), when the service consumer looks up the provider URI at every invocation. The registry will load balance the requests by returning different URIs. This solution won't act as a security gateway and the consumers may ignore it alltogether
  5. build your own, if you need some advanced adaptive load balancing algorithm or if you want a non-standard security layer. Let's forget about non-standard security, it is rarely a good idea, but adaptive load balancing can be desirable. Options 1-3 will do round-robin or weighted round robin or adaptive round robin based on response times and they will detect unresponsive instances. Options 1 and 3 provides another difficult to implement feature, the HTTP session stickyness as well, but it is not necessary for SOAP or REST services
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文