根据 API key 将请求发送到其他服务器

发布于 2024-09-29 18:09:40 字数 589 浏览 2 评论 0原文

我正在设计一个应用程序,要求对我们服务器的所有请求都通过单个“调度程序”类型服务器进行路由。该服务器将根据请求中发送的 API 密钥,将请求转发到适当的后端服务器,然后将响应转发回客户端。

例如,传入请求可能是 http://example.com:6578//create?name=example&date=title

我的第一反应是使用 PHP 和 Lighttpd 来实现调度程序,并使用 membase 存储 api-key/服务器映射。然而,该路由器最终可能会路由大量请求,因此性能是关键。

同时,带有 APC 的 Lighty 速度相当快,并且可水平扩展。

对于应该用于此类事情的语言/架构有什么建议吗?

编辑:键值对将从 membase 或类似的键值存储中获取。因此,对于 api_key 1234,membase 将返回 IP 123.456.789.101。然后,我们将执行请求转发到 http://123.456.789.101//create?name=example,并将响应返回给客户端。

I am designing an app that requires that all requests to our servers be routed through a single 'dispatcher'-type server. This server will, based on an API key sent in the request, forward the request on to an appropriate backend server, than relay the response back to the client.

eg., an incoming request could be http://example.com:6578/<api_key>/create?name=example&date=title

My first instinct is to use PHP with Lighttpd for the dispatcher, and store the api-key / server mappings with membase. However, this router could end up routing a huge number of requests, so performance is key.

At the same time, Lighty with APC is quite fast, and horizontally scalable.

Any suggestions for languages / architectures that should be used for something like this?

Edit: Key-value pairs would be fetched from membase or a similar key-value store. So, for and api_key of 1234, membase will return the IP 123.456.789.101. We would then forward perform the request to http://123.456.789.101/<client>/create?name=example, and return the response back to the client.

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

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

发布评论

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

评论(1

杀手六號 2024-10-06 18:09:40

在我看来,这就像你应该用 nginx 做的事情。 Nginx 一直用于转发/代理连接。如果您想水平扩展,请将一堆 nginx 盒子放在负载均衡器后面。

This seems to me like something that you should do with nginx. Nginx is used all the time for forwarding/proxying connections. If you wanted to scale horizontally, throw a bunch of the nginx boxes behind a load balancer.

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