TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

The Slotted Counter Pattern

2 点作者 nedp将近 3 年前

1 comment

josephcsible将近 3 年前
&gt; It is a common database pattern to increment an INT column when an event happens, such as a download or page view.<p>&gt; You can go far with this pattern until bursts of these types of events happen in parallel and you experience contention on a single row. When multiple transactions are trying to update the counter, you are essentially forcing these transactions to run serially, which is bad for concurrency and can cause deadlocks.<p>I can see how that would cause slowdowns, but not deadlocks, unless by &quot;cause&quot; it means &quot;trigger one that was already present all along due to a bug in your code&quot;. Well-written code should work completely fine (other than being slow) with that pattern.