如何重复使用连接或使用Apollo-Server REST DataSource的GraphQl中的连接池

发布于 2025-01-24 17:04:39 字数 825 浏览 1 评论 0原文

我有一个带有apollo-serverapollo-datasource-rest库的GraphQl Server作为处理REST DataSource Connections的库。

由于大量的并发请求,我面临着一个从GraphQL到我的云托管服务的太多连接的问题。

当GraphQL Server向REST服务发出请求时,通过使用用于出站连接的azure snat

但是,由于每个新请求上的连接数量很高,因此SNAT端口的连接数量大。

避免此问题的可能方法之一是使用连接池或重用新请求的现有连接本文

我的问题是如何重用阿波罗 - 服务器中的现有连接或如何实现连接池,以便我解决此问题。

I have a GraphQL server with apollo-server and apollo-datasource-rest as library to handle REST datasource connections.

I am facing an issue of opening too many connections from GraphQL to my cloud hosted services due to a high number of concurrent requests.

When the GraphQL server fires a request to a REST service there is a middle step in the cloud infrastructure to get service's private ip by using Azure SNAT for outbound connections

However, due to the high number of connections on every new request the SNAT ports get exhausted.

One of the possible ways to avoid this problem is to use connection pooling or reuse existing connections for new requests according to this article.

Possible ways to solve port exhaustion

My question is how to reuse existing connections in Apollo-server or how to implement connection pooling so I solve this issue.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文