在 Redis 中存储会话时的 Asp.net 性能问题

发布于 2025-01-12 10:54:38 字数 898 浏览 4 评论 0原文

从在 SQL 中存储会话转换为在 Redis 中存储会话时,我们发现了一个主要的性能问题。我希望您能为我们提供一些可能导致此问题的提示。

技术设置:

  • 在.net Framework 4.72 中编译的asp.net 网站。
  • 旧的 Redis 版本 3.2(Microsoft 为 Windows 编译的版本)在同一服务器上运行。
  • Nuget: ASP. NET 会话状态提供程序
  • Nuget:Stackexchange.Redis

运行性能负载测试时,随着虚拟用户 (VU) 数量的增加,大约 400-500 个虚拟用户的服务器会遇到某种问题wall,仅处理少量请求,如下图所示:

性能问题图

性能测试由 k6.io 从远程服务器进行。

另一项测试表明,当过载时,服务器会停止处理1-2秒,然后在不到1秒的时间内处理大量数据,然后再次停止,依此类推。因此它会遇到某种拥塞,可能是队列已满或某种类型的锁。

查看服务器 CPU 使用率,当问题出现时,它会显着下降。

即使我尝试复制相同的设置,我也只能在我们的服务器上复制它,而不能在我的本地计算机上复制它。

是否使用 Binary og JSON 序列化器将数据序列化到 Redis 也存在同样的问题。

In converting from storing sessions in SQL to instead storing sessions in Redis, we are seeing a major performance issue. I hope you are able to give us some hints on what could cause this.

The technical setup:

  • An asp.net website compiled in .net framework 4.72.
  • An old Redis version 3.2 (Microsoft compiled version for Windows) running on same server.
  • Nuget: ASP.NET Session State Provider
  • Nuget: Stackexchange.Redis

When running a performance load testing, with increasing number of virtual users (VUs), the server at about 400-500 virtual users hits some kind of wall, only processing a low number of requests as seen in this diagram:

performance issue diagram

The performance testing is made by k6.io from a remote server.

Another tests shows that when overloaded, the server for 1-2 seconds stops processing and then processes a lot in less than 1 seconds, and then stops again and so on. So it experiences some kind of congestions, maybe a full queue or lock of some kind.

Looking into the server CPU usage, it just drops significantly when the issues arises.

I can only reproduce it on our server, not my local machine, even though I have tried replicating the same setup.

Same issue whether serializing data to Redis using Binary og JSON serializer.

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

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

发布评论

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

评论(1

Smile简单爱 2025-01-19 10:54:38

我找到了解决方案。 Stackexchange.Redis 似乎没有更新到最新版本。更新到最新版本解决了我的问题

I found a solution. It appeared that Stackexchange.Redis was not updated to latest version. Updating it to latest version resolved my issue

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