使用Golang通过dataplane API将新服务器添加到HAProxy,并进行速率限制。

huangapple go评论75阅读模式
英文:

Add new server to HAProxy using dataplane api with Rate limiting in Golang

问题

我正在通过我的 Golang 代码向 Haproxy 添加新的后端服务器。我可以看到在添加新服务器时有一个名为 max connections 的参数,可以用于限制连接数。还有一个名为 maxqueue 的参数,如果达到最大连接限制,它将排队连接。但是我找不到指定队列超时的选项。而且我在文档中也找不到默认的队列超时时间。

此外,在向后端添加新服务器时,如何基于请求数(滑动窗口)进行速率限制?
我可以看到有一个选项可以提及 stick table,但是我找不到其实现的示例。

我参考了以下文档。
https://www.haproxy.com/documentation/dataplaneapi/community/#post-/services/haproxy/configuration/servers

英文:

I am adding new backend server to Haproxy through my golang code. I can see there is a parameter called max connections while adding new server which can be used to limit no of connections. There is also a parameter called maxqueue which will queue the connections if max connection limit is reached. But I cant find-out the option to specify the queue timeout. And I could not find from documentation what is default queue timeout time.

Furthermore, How can I add rate limiting based on no of requests (sliding window) while adding new server to backend?
I can see there is an option of mentioning stick table however I could not find example of its implementation.

I am referring to below documentation.
https://www.haproxy.com/documentation/dataplaneapi/community/#post-/services/haproxy/configuration/servers

答案1

得分: 1

一个服务器没有"队列超时"。您可以通过后端配置来设置"队列超时"。

https://www.haproxy.com/documentation/dataplaneapi/community/#post-/services/haproxy/configuration/backends
https://www.haproxy.com/documentation/dataplaneapi/community/#put-/services/haproxy/configuration/backends/-name-

可以通过默认调用来获取默认值。
https://www.haproxy.com/documentation/dataplaneapi/community/#get-/services/haproxy/configuration/defaults

英文:

A server have no "queue timeout". You can set the "queue timeout" via the backend configs

https://www.haproxy.com/documentation/dataplaneapi/community/#post-/services/haproxy/configuration/backends
https://www.haproxy.com/documentation/dataplaneapi/community/#put-/services/haproxy/configuration/backends/-name-

The defaults can be received via the defaults call.
https://www.haproxy.com/documentation/dataplaneapi/community/#get-/services/haproxy/configuration/defaults

huangapple
  • 本文由 发表于 2022年10月12日 19:06:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/74040810.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定