linux - 如何处理 http 客户端的最大连接数问题?
问题描述
我们有一个 http GET 处理程序(ProductHandler
),它反过来使用 http 客户端连接到另一个服务器。
type ProductHandler struct {
service1 Service1
service2 Service2
}
type Service2 struct {
field1 int
field2 string
client CustomHttpClient
}
CustomHttpClient
使用http.Client
来自的类型https://golang.org/src/net/http/client.go
由于http.Client
并发安全,我们通过注册 GET 请求来使用单个 http 客户端来处理多个 GETProductHandler{}
请求。
GET 请求由http.Server
from提供服务https://golang.org/src/net/http/server.go
但问题是,由于 Linux 中的文件描述符数量(默认 1024)是有限的,因此http.Client
限制了 GET 请求的数量。ProductHandler
具体来说,受Linux文件描述符MaxConnsPerHost
的限制。http.Transport
如何解决 GET 请求受文件描述符数量限制的问题CustomHttpClient
?提高ulimit
只是一个工作...
解决方案
推荐阅读
- android - Android Oreo:使用 Intent.createChooser 包装时,来自 ACTION_GET_CONTENT 的 URI 未授予 FLAG_GRANT_READ_URI_PERMISSION
- javascript - 找出哪个变量的值最小
- wpf - DataGridTemplateColumn.CellEditingTemplate ComboBox 在单击两次之前不显示
- google-cloud-platform - 为什么 Google Cloud Storage 不发送正确的缓存标头?
- angular - 如何更新 Angular 项目中的 README.md 文件?
- apache-spark - 如何设置一个微批次的最大行数?
- python-3.x - 决定机器人是否在聊天室或 PM 中响应
- google-cloud-platform - 如何将默认 gcp 服务帐户设置为云作曲家
- laravel-5 - 如何仅在刀片中为空、零或空时隐藏表格部分,
- swift - 如何创建一个提取来总结属性之间的差异