Skip to content

Commit

Permalink
优化 HTTP 请求处理性能和资源利用
Browse files Browse the repository at this point in the history
在 `DHWeb.cs` 文件中的 `DHWeb` 类中,增加了以下代码:
* `ServicePointManager.ReusePort = true;`  // 允许不同的 HTTP 请求重用相同的本地端口。
* `ServicePointManager.Expect100Continue = false;`  // 禁用 100-Continue 行为,可能会提高性能。

这些更改通过设置 `ServicePointManager.ReusePort` 和 `ServicePointManager.Expect100Continue` 属性,优化了 HTTP 请求的处理性能和资源利用。
  • Loading branch information
猿人易 committed Dec 19, 2024
1 parent 3cd2aa2 commit dfc3591
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Pek.AspNetCore/Helpers/DHWeb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ static DHWeb()
{
Environment = Pek.Webs.HttpContext.Current.RequestServices.GetService<IWebHostEnvironment>();
ServicePointManager.DefaultConnectionLimit = 10000000; // 用来限制客户端请求的并发最大连接数

ServicePointManager.ReusePort = true; // 可以让不同的HTTP请求重用相同的本地端口。

ServicePointManager.Expect100Continue = false; // 询问服务器是否愿意接受数据,禁用此选项可能会提高性能。
}
catch
{
Expand Down

0 comments on commit dfc3591

Please sign in to comment.