Why would the count be lost under high concurrency when the visit volume is written to the database in real time each time, and what does the aggregation rewrite solve?

📅 2026-10-11 👁️ 15

Why does the real-time writing of access volume cause the loss of counting under high concurrency? The reason lies in this writing method, which is 'read-modify-write': first read the current value, add one and write it back. Two requests read the same old value at the same time, add one after writing back, and the number written to the database is the same, and the increment is overwritten once. The higher the concurrency, the greater the probability of overlapping reads, and the lost are not just a few sporadic ones.

What section is lost?

The lost is the increment, not the entire data block. It is manifested as the statistical number being significantly lower than the actual request volume in the logs, and the deviation expands with the increase in traffic; it is not noticeable on a single page, and aggregated reports may show situations such as 'Today's visits are less than the details'.

The second type of loss is more concealed: accounts are settled without being written to disk. The memory has already marked this batch of increments as processed, but it has not been written to persistent storage yet. At this point, if the process exits or the machine restarts, this increment will be permanently lost. In the public version records, some people have written these two things into the same fix: PbootCMS recorded in V3.2.21 that 'changed the real-time writing of access volume to reliable increment aggregation backwriting, and fixed the problem of increment loss and settlement without being written to disk in concurrent scenarios.'

What did the aggregation backwriting change?

Aggregate rewrite changes 'write once per access' to 'accumulate a segment of increment and write once in batch'. The effect has two layers: first, the number of write times decreases, and the contention of hot rows is reduced; second, read-modify is moved out of the request path and modified to accumulate in a single-threaded or controlled task, possibly eliminating the overwritten data.

After the modification, still need to pay attention to three things.

Link The problems to be solved Common practice
Accumulate Concurrent overwrite on the request path Increment first into memory or queue, do not modify the line directly in the request
Disk write Charge off without persistence Write successfully before clearing the buffer, replay on failure
Recovery Where did the increment received after the crash go Keep the data waiting to be rewritten and the queue position that can be replayed
Search Detailed and summary口径 are inconsistent The settlement is based on a fixed time point, and the report indicates the cut-off time

The order is very important: first write to disk, then settle accounts. Otherwise, it will return to the old problem of not writing to disk and settling accounts

How to divide the storage tier

Statistical writes should be separated from business tables. High-frequency append data such as access details and spider logs, if挤在同一个存储里and business tables are stored in the same storage, high-frequency writes will drag down the overall performance, and additional risks will occur during concurrent directory creation or the first write. Place log data in independent text or dedicated storage, segmented by time, and only keep transactionally guaranteed data in business tables, with no interference between the two types of reads.

The crawling traffic within the site should be separated from the real visitors. The anti-crawling and interference codes are aimed at the batch transfer of content, and the criteria include visitor behavior characteristics; mixing this traffic with the normal crawling of search engines into a single number will already lead to an inaccurate statistical scope.

How should the official carrying scope be read?

The official statement of AnQiCMS is that the page loading speed is significantly improved compared to traditional PHP CMS, and it can handle about 5 million PV on a single machine, with memory usage reduced by about 80% compared to PHP CMS. These numbers are approximations, not benchmarking indicators: they describe the level of difference under the same resources and cannot be directly converted to 'how many concurrent connections' or 'how many times'.

What truly determines whether the statistical write can withstand it is the other links in this chain: how many read requests are blocked by the cache, how much write amplification the database has, and how often the aggregation task runs. When you see any number of 'how much a single machine can bear,' you should also ask what other variables are on the same chain.

Common questions

Should the statistics be precise to each visit?It depends on the purpose. For operational trends, you can just look at the aggregated values; for counting involving billing or settlement, there must be a detailed source that can be accounted for, not just relying on memory accumulation.

What are the problems with putting log and transaction data together?High-frequency addition will amplify the write pressure and lengthen the transaction, and the retention period and cleaning methods of the two types of data are also different. It is better to execute the strategies separately after they are separated.

Will the push and statistics affect each other?They will share the exit bandwidth and queue. The link push and active push should be queued according to the crawling rhythm to avoid competing for the same resource with high-frequency statistical writing.

Related articles

The third-party panel says that you can see which AI services are collecting content by opening the box, and what the site can do with this record

This type of panel provides network-level collection visibility: which AI services are accessing, whether there is a violation of the exclusion instructions. This article explains what this record can and cannot answer, as well as how the site aligns it with its own exclusion configuration, site description file, and access statistics before using it.

2026-10-11

An audit has found that about one-tenth of the cited sources in AI answers are self-generated by the model. How should the content site view this number?

An audit of four generative search engines found that about 16% of the cited sources are synthetic sources generated by machines. This article explains that this number describes the composition of the citation list, not the content quality rating, and provides several links to maintain the source distinguishability on the site side.

2026-10-11

It was found that the answers cited first are often the entries at the top of the list, how should the page structure be arranged?

A cross-model test of six models, with a scale of 250,000 times, shows that thematic relevance and list position are the main factors determining the priority of the source being cited. Clear price information and newer timestamps also continue to help. This paper applies these conclusions to the layout of page structure, content model, and publication time.

2026-10-11

Vector icons can carry scripts, and when uploading images, it is necessary to filter out what content should be blocked.

Vector icons are not image data, but a document format that can include script elements. When uploading, it is necessary to filter out scripts and event attributes, external references, and large decompression volumes, while retaining normal display content. This article discusses the trade-offs between the cleaning list and black and white list strategies.

2026-10-11

The major version of the blog program came out after three years, and what can be read from the change list.

Judging the maintenance activity of a blog program or content management system, it is not about how much the version number has increased, but about the time span between major versions, the composition of change items, and the distribution of repair types. This article compares two rhythms using published records and gives four items for the core selection of website building.

2026-10-11

When the same directory in robots.txt allows and prohibits crawling with one rule each, which one should be followed

When the same directory is both allowed and prohibited from crawling, the order of judgment is specified by the protocol: take the one with the most matching bytes. This article explains the priority of conflicting entries, the differences in case of paths and group names, and how to avoid such conflicts in site configuration according to the original text of the protocol.

2026-10-11

After submitting the sitemap, it has not been indexed yet. Besides waiting, what else can be done actively?

Submitting the sitemap does not mean that the page has been indexed. The former provides clues for discovery, while the latter depends on the scheduler of the indexing party. This article explains the division of labor between the two and provides methods for actively pushing notifications for new additions and changes, as well as lists the troubleshooting sequence when the push does not take effect.

2026-10-11

There is a paper that says the generative engine optimizes the evidence pool and generation link, what can the content site cooperate with?

An editorial paper describes the optimization object of the generative engine as the evidence pool and generation process of the engine, rather than page ranking. The station can cooperate not by guessing the algorithm, but by making the source identifiable and the content quality verifiable, and avoiding the three methods mentioned in that paper.

2026-10-11