读取 ASP.NET 会话变量非常慢(30 秒)!
在调试执行缓慢的操作时,我发现(令我惊讶的是)该行:
if (HttpContext.Current.Session["CurrentCompany"] == null)
需要大约 30 秒 来执行。
可能发生什么事情!?有人见过这样的事情吗?
(它位于具有 StateServer 存储会话的负载平衡配置中,这可能相关吗?)
Debugging an operation that's performing slowly, I've discovered (to my astonishment) that the line:
if (HttpContext.Current.Session["CurrentCompany"] == null)
takes about 30 seconds to execute.
What could possibly be happening!? Anyone seen anything like this before?
(It's in a loadbalanced config with StateServer storing session, could that be related?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了一个解决方法:我将 web.config 中的会话提供程序
从“StateServer”更改为“InProc”:
...并且暂停消失了。
(很可能它无法到达状态服务器,当前服务器不是它最初运行的位置)。
感谢您的所有建议,特别是@Hari 和@dougajmcdonald。
。
事后编辑
这可能会对以后的人有所帮助:这个问题的根本原因似乎是一种方法,它发出了大量非常繁重的 SQL 查询,这些查询与这个状态服务器问题大约在同一时间发生。我认为这些是相关的,但不确定如何相关。从那以后我遇到了类似的问题,所以如果您遇到这样的会话问题,请查找大量的数据库活动。
I found a workaround: I changed the session provider in the web.config:
from "StateServer" to "InProc":
... and the pause went away.
(Most likely it had trouble reaching the stateserver, the current server is not where it was originally running from).
Thanks to all your suggestions, especially @Hari and @dougajmcdonald.
.
Hindsight edit
This may help someone later: The root cause of this issue seems to have been a method that made a huge number of very heavy SQL queries that occurred around the same time as this stateserver problem. I think these are related, not exactly sure how. I've had similar problems since, so if you have a session issue like this, look for heavy DB activity.