asp.net-mvc / SQL Server 中存储昂贵的计算数据并像 stackoverflow 一样快速提供服务的最佳方法是什么

发布于 2024-10-31 22:13:06 字数 305 浏览 2 评论 0原文

我对 stackoverflow 有类似的要求,要在我的 asp.net-mvc 站点的页面上显示许多计算成本非常昂贵的指标。 Stackoverflow 页面上有很多指标(例如用户接受率等),这些指标显然不是根据页面请求动态计算的,因为它太慢了。

在不影响性能的情况下快速提供计算数据的推荐做法是什么(假设我们可以接受该数据可能有点过时。

它是存储在某个缓存层中还是存储在其他“结果”数据库表中,因此每个有一天,有一项工作来计算这些数据并存储结果,以便可以直接查询它们?

假设我很乐意处理将此数据作为快照的延迟,那么此类问题的最佳解决方案是什么。

i have a similar requirement to stackoverflow to show a number of metrics on a page in my asp.net-mvc site that are very expensive to calculate. Stackoverflow has a lot of metrics on the page (like user accept rate, etc) which clearly is not being calculated on the fly on page request, given that it would be too slow.

What is a recommended practice for serving up calculated data really fast without the performance penalty (assuming we can accept that this data maybe a little out of date.

is this stored in some caching layer or stored in some other "results" database table so every day there is a job to calculate this data and store the results so they can be queries directly?

assuming that i am happy to deal with the delayed of having this data as a snapshot,what is the best solution for this type of problem.

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

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

发布评论

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

评论(3

忘东忘西忘不掉你 2024-11-07 22:13:06

他们可能依赖 Redis 数据存储来进行此类计算和缓存。 marcgravell 的这篇帖子可能会有所帮助。

Probably they may be relying on the Redis data store for such calculations and caching. This post from marcgravell may help.

靖瑶 2024-11-07 22:13:06

是的,答案是缓存,你如何做到这一点是(可能是)复杂的部分,如果你使用 NHibernate 添加缓存真的很容易,是你的配置的一部分,并且在你只需添加 .Cacheable 的查询上,它会管理它你。缓存还取决于环境类型,如果您使用单个工作线程、网络场或网络花园,则必须构建一个缓存层来适应您的场景

yes, the answer is caching, how you do it is (can be) the complicated part, if you are using NHibernate adding caching is really easy, is part of your configuration and on the queries you just add .Cacheable and it manages it for you. Caching also depends on the type of environment, if you're using a single worker, web farm or web garden, you would have to build a caching layer to accomodate for your scenario

痕至 2024-11-07 22:13:06

尽管这是一种较新的技术,但构建系统以使此类内容成为可能的一种真正好的方法是使用 命令和查询职责分离,更常被 CQRS 提及。

Although this is a somewhat-recent technique, one really great way to structure your system to make stuff like this possible is by using Command and Query Responsibility Segregation, more often referred to by CQRS.

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