WCF 服务:ASP.NET 缓存或 SQL

发布于 2024-09-10 17:26:20 字数 300 浏览 2 评论 0原文

我目前正在开发将在 Microsoft Azure 上运行的 WCF REST Web 服务。为了限制每个 IP 地址的请求数量以防止滥用,我当前使用 ASP.NET 缓存存储 IP 和超时。

此方法效果很好,但由于 Azure 的多个 VM 实例不共享单个缓存,因此请求可能会在不同 VM 之间拆分,并在 VM 重置时被清除。

我不认为这是一个主要问题,但由于我已经将用户信息存储在 SQL Azure 数据库中并使用 WCF 服务对用户进行身份验证,因此使用数据库而不是 ASP.NET 缓存会更好吗?

任何adive都会非常有帮助。

I'm currently developing a WCF REST Web Service that will be running on Microsoft Azure. To limit the number of requests per IP address to prevent abuse, I currently store the IP and timeout using the ASP.NET Cache.

This method works great but since muliple VM instances with Azure don't share a single cache, the requests could be split between different VMs and be cleared if a VM is reset.

I don't think this is a major problem but since I already store user info in a SQL Azure database and authenticate users using the WCF service, would I be better off using the database instead of the ASP.NET cache?

Any adive would be really helpful.

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

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

发布评论

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

评论(2

往事风中埋 2024-09-17 17:26:20

使用混合方法怎么样?除了将其放入缓存之外,您还可以将其存储到 SQL 数据库中。然后,当它们到达不同的实例时,它会与数据库中存储的时间一起放入缓存中。最大限度地减少数据库的往返次数,并使信息可供所有服务器使用。

What about using a hybrid approach? You could store it into the SQL database in addition to putting it in your cache. Then when they hit a different instance it is put into the cache with the time that was stored in the database. Minimizes round trips to the database, and makes the information available to all of the servers.

属性 2024-09-17 17:26:20

您必须决定何时可以接受阈值。
来自缓存的数据会更快,但存在不代表实际当前数据的风险。从数据库获取数据是新鲜事,但往返数据库需要时间。

You have to decide when the threshold is acceptable.
Data from cache will be faster, but there's a risk it doesn't represent actual current data. Where fetching data from the database is fresh, but it takes time to make the trip to the database and back.

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