在镜像上使用 ASP.NET 应用程序缓存的潜在问题?

发布于 2024-09-25 16:52:51 字数 133 浏览 1 评论 0原文

我有两台带有负载均衡器的镜像服务器。我想知道坚持使用应用程序缓存与使用内存缓存之类的东西的优缺点?我对各种解决方案非常感兴趣,尤其是由于不同步它们而可能出现的错误类型或限制。

首先,我冒昧地说,使用 ASP.NET 缓存会更快、更简单。

I've 2 servers mirror with a load balancer. I'd like to know the pros and cons of sticking with app cache versus going with something like memcache? I'm very interested in various solutions and especially the types of errors that I could get or limitations by not synchronizing them.

To start the discussion, I'd hazard that using ASP.NET cache would be faster and simpler.

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

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

发布评论

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

评论(1

云裳 2024-10-02 16:52:51

最好建议您将缓存抽象为一个接口,以多种方式实现该接口并测试不同的实现。

在许多情况下,问题在于查看数据以及不同用户之间共享的数据量。

ASP.NET 缓存不一定更快或更简单。这取决于您缓存的量以及网络服务器是否有资源来处理它。在大多数合理大小的应用程序中,答案通常是否定的。

缓存服务器之间不同步的主要缺点是,在负载平衡的环境中,对相同数据的后续请求可能会发送到不同的服务器。这仅意味着数据库有时会受到两次攻击。缓解这种情况的一种方法是实现粘性会话,其中给定的用户始终被发送到同一服务器,并且负载均衡器仅在用户会话开始时做出平衡决策。

You are best advised to abstract the caching into an interface, implement the interface in a number of ways and Test the different implementations.

As in many cases, it is a matter of looking at the data and how much it is shared between different users.

ASP.NET cache would not necessarily be faster or simpler. It depends on how much you are caching and whether the webservers have the resources to handle it. In most reasonable size apps, the answer to that is often No.

The main downside to not synchronizing between cache servers would be that in a load balanced environment, subsequent requests for the same data might go to different servers. This would just mean that the database gets hit twice some of the time. A way to mitigate this is to implement sticky sessions, where a given user is always sent to the same server and the load balancer only makes a balancing decision at the start of a user session.

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