Designing a Content Column System: From Dynamic Feeds to Reliable Favorites
This article explains how to design a content column system that separates articles, feed events, and favorites; defines clear visibility and lifecycle rules; uses idempotent APIs and cursor-based pagination; and keeps transactions, events, caches, permissions, and operational safeguards consistent under concurrency, retries, and failures.
1. Reconstructing System Requirements from Page Entries
A content column page often exposes only a few visible entries, such as “Feed” and “Favorites.” Behind them, however, are two different ways of organizing data: the feed emphasizes how content changes over time, while favorites emphasize a user’s long-term preservation of content. When designing the system, these should not be treated as two simple lists. The relationships among content, actions, permissions, and lifecycle must be made explicit.
This article uses a general content column scenario to discuss article publishing, feed display, and user favorites. Here, a feed event refers to a content event generated when an article is published or updated; it does not extend to complex social relationship recommendations.
The system first needs to answer three questions.
First, what content can be displayed? Draft, under review, published, withdrawn, and deleted articles should have clear boundaries.
Second, what exactly does a user favorite? Typically, the user favorites the stable identifier of an article, not the result of a particular page rendering. Therefore, the favorite relationship should remain valid even after the article title is updated.
Third, what happens when content is no longer visible? An article may be withdrawn by its author or become inaccessible due to permission changes. Whether the favorite record is retained, how the list indicates the state, and whether the user can remove the favorite all need to be defined in advance.
These rules determine the subsequent data structures and API behavior and should be settled before page implementation.
2. Domain Modeling: Separating Articles, Feed Events, and Favorite Relationships
2.1 Articles Carry Content Facts
An article entity stores the content itself and its current state. It may include the following logical fields:
- Article identifier and author identifier;
- Title, summary, and body reference;
- Publishing status and access scope;
- Creation time, publication time, and update time;
- Content version number.
When the body is small, it can be stored together with article metadata. When the body is large or has many historical versions, the body and metadata can be managed separately. Whether to split them should depend on access patterns, transaction requirements, and maintenance cost, not on pursuing architectural complexity for its own sake.
The version number is used to identify content changes. When an author opens multiple editing pages at the same time, version validation can prevent a later submission of older content from overwriting newer changes.
2.2 Feed Events Are Events, Not Article Copies
A feed record describes “what happened to an object,” for example, the first publication of an article. It usually contains an event identifier, article identifier, event type, occurrence time, and a small number of snapshot fields needed for display.
A feed event should not fully copy the article body. Otherwise, every article update may cause duplicate updates and consistency problems. Display fields such as the title may retain a snapshot, but their semantics must be explicit: should they show the title at the time of the event, or the current title of the article?
In addition, not every content modification should produce a new feed event. Fixing punctuation and rewriting a core paragraph have different meaning for readers. In an initial system, a feed event can be generated only on first publication, avoiding a feed list flooded by frequent edits.
2.3 Favorites Are Relationships Between Users and Articles
A favorite relationship needs at least a user identifier, article identifier, favorite time, and relationship state. A unique constraint on the combination of user and article prevents duplicate records.
Whether to retain canceled relationships depends on auditing, statistics, and storage cost. Physical deletion is simple. State retention makes changes easier to trace, but a retention period must be defined to avoid unlimited accumulation of personal behavior data.
Favorite relationships should also be separated from favorite counts. Relationship records are used to determine whether a specific user has favorited an article, while counts are used to display the total. The two can use different update strategies, but relationship records should serve as the basis for verification and repair.
3. API Semantics: Making Retries Safe for Business Results
A network timeout does not mean the server did not complete the operation. After a user clicks Favorite, if the response is lost, the client may submit the request again. Therefore, the favorite API must consider idempotency.
The API should not be designed as “toggle favorite state.” If the same request is executed twice, the first call favorites the article and the second unfavorites it, producing a result opposite to the user’s intent.
A safer approach is to express the target state:
- Set to favorited;
- Set to not favorited;
- Query the current favorite state.
The following is an illustrative flow, not an API from a specific product:
setFavoriteState(currentUser, articleId, targetState):validate identityvalidate the target article according to the operation typebegin transactionread and lock the existing relationship, or rely on a unique constraint to handle first-write conflictsif current state equals target state:do not produce a duplicate state changeelse:write the target staterecord the corresponding change informationcommit transactionreturn the confirmed state
A unique constraint cannot be replaced by “query first, then insert,” because two concurrent requests may both see that no record exists. The first write still needs to rely on database constraints and conflict handling to guarantee correctness.
Removing a favorite should not depend on the article still being visible. Even if the article has been deleted or has lost access permission, the user should generally still be able to remove their own favorite relationship.
4. Pagination Design for Feed and Favorite Lists
4.1 Define the Sort Basis Clearly
Feed events are usually displayed in reverse chronological order by event time, and favorite lists are usually displayed in reverse chronological order by favorite time. Article update time should not affect favorite position by default; otherwise, every author edit could change the user’s favorite order.
Time fields may be identical, so sorting needs a stable secondary field, such as a combination of “favorite time, relationship identifier.” The secondary field should be unique and comparable to ensure a clear ordering result.
4.2 Prefer Cursor-Based Pagination
Offset-based pagination is simple to implement, but when new content is continuously inserted at the top of the list, paging can produce duplicates or omissions. When the offset is large, query cost may also increase.
Cursor-based pagination stores the sort position at the end of the previous page, and the next page continues reading after that position. For example, when the favorite list is sorted in descending order by time and relationship identifier, subsequent queries should strictly read records whose sort position is later.
Cursors should preferably be generated and validated by the server, preventing clients from arbitrarily modifying internal query conditions. However, a cursor is not a permission credential; every request still needs to verify user identity and resource access permissions.
Note that cursor-based pagination only improves stability during continuous browsing. It does not automatically provide a complete snapshot across multiple pages. If a user removes and re-adds a favorite while paging, its position may still change. This limited change is acceptable for ordinary lists; for export or audit scenarios, a more explicit snapshot boundary should be used.
4.3 Control Batch Read Cost
After obtaining a page of favorite relationships, article metadata should be queried in batches rather than read one by one. Additional data such as user favorite state and author information should also be fetched together where possible, avoiding an extra request for every record.
For articles that are no longer visible, the system can show a simplified placeholder and allow removal, or filter them out during reading. However, filtering may result in fewer than one page of results. Whether to continue fetching more records requires a scan limit to prevent a large number of invalid records from causing one request to traverse indefinitely.
5. Consistency Across Transactions, Events, and Caches
5.1 Prioritize Reliability of Core Relationships
Article state and favorite relationships are business facts and should be persisted correctly first. Derived information such as favorite totals and popularity rankings can tolerate short delays according to business requirements.
If favorite relationship writes and count updates are in the same database transaction, the logic is straightforward, but the count row of a popular article may become a write hotspot. As scale grows, count updates can be made asynchronous while accepting a short lag in displayed values.
Asynchronous consumption must prevent duplicate processing. Only a real state change should produce one count change; request retries must not cause repeated increments or decrements.
5.2 Avoid the Dual-Write Gap Between Database and Messaging
If a favorite relationship is committed first and a change message is sent afterward, the service may fail between the two steps, leaving the relationship changed but the count not updated.
A common approach is to write the relationship change and the pending event in the same transaction, then have a background task deliver the event. Event consumers deduplicate by unique event identifier and support retries on failure. This still requires handling delivery delays and duplicate messages, but it narrows the inconsistency window between fact recording and event publication.
5.3 Caches Only Accelerate Access
Article summaries, public metadata, and some aggregate counts are suitable for caching. For a user’s personal favorite state, the key space should be designed carefully to prevent data leakage between different users.
A common strategy is to invalidate related caches after a successful database update and set a reasonable expiration time. Deleting a cache does not eliminate all concurrent races. For example, an old query may write an old value back after invalidation. Therefore, version validation, short expiration, or later repair mechanisms are also needed to control the impact.
When the cache is unavailable, the system should choose rate limiting, degradation, or controlled cache-miss handling based on database capacity, rather than letting all requests hit the database at the same time.
6. Permission Governance and Content Lifecycle
Favoriting an article does not grant the user a permanent right to access it. After an article changes from public to restricted, both the favorite list and the detail API must re-run permission checks.
In particular, avoid leaking information through list summaries. Even if the detail page denies access, the list may still expose restricted information if it continues to return the old title, summary, or body fragment. Permission checks should cover returned fields, not only whether the body can be opened.
Article deletion can distinguish between logical deletion and final cleanup. Logical deletion stops display promptly; final cleanup handles the body, attachments, caches, and derived indexes according to retention policy. When personal behavior records are involved, the principle of necessity should also apply, with clear access scope and cleanup periods.
Whether a favorite list is public should be determined by clear business rules or user settings. It should not be exposed by default simply because it is technically easy to query.
7. Performance Optimization and Operational Safeguards
7.1 Design Indexes Around Query Paths
Common queries on the favorite table include “whether a user has favorited a specific article” and “which articles a user recently favorited.” The former requires a unique constraint on user and article. The latter usually requires a composite index covering user, relationship state, and sort fields.
More indexes are not always better. Every additional index increases write and maintenance cost. Its value should be judged through actual query plans, data distribution, and load testing.
7.2 Distinguish Display Degradation from Core Writes
When the favorite total is temporarily unavailable, the count can be hidden. When feed recommendations fail, the system can fall back to basic time-based sorting. But when a favorite write fails, the page should not simply show success.
The client can provide immediate interaction feedback, but the state must be confirmed according to the server result. On failure, it should roll back and notify the user. Repeated clicks, out-of-order requests, and cross-device operations also need coordination through request ordering control, state versions, or re-querying.
7.3 Establish Actionable Observability Metrics
In addition to request success rate and response time, attention should be paid to unique constraint conflicts, transaction retries, event backlog, duplicate consumption, count calibration differences, cache hit rate, and permission denials.
Metrics need to correspond to concrete actions. For example, when event backlog continues to increase, the team should determine whether production speed has risen, consumption capacity is insufficient, or a downstream system has failed, rather than merely raising the alert threshold. Logs should contain the necessary troubleshooting identifiers and avoid sensitive information such as body content and access credentials.
8. Testing and Incremental Implementation Path
Testing should not only verify a single successful click. It should also cover repeated favoriting, repeated unfavoriting, concurrent favorite and unfavorite operations, response loss after write, abrupt article state changes, duplicate message delivery, and cache failures.
In particular, several business invariants need to be verified: the same user and article do not have multiple valid relationships; removing a favorite does not cause a negative count; invisible content is not leaked through lists; and failed retries do not produce additional business changes.
Implementation can proceed in stages.
In the first stage, establish clear models for articles, feed events, and favorites, and complete unique constraints, permission checks, and basic pagination.
In the second stage, add idempotent handling, stable sorting, batch reads, and key monitoring so that the feature has verifiable correctness.
In the third stage, introduce caching, asynchronous counting, and event compensation based on real bottlenecks, while retaining reconciliation and repair paths.
The difficulty of a content column system is not in adding a few display entries. It is in keeping the semantics of content states, user relationships, and derived data clear under concurrency, retries, and failures. Ensure facts are reliable first, then optimize query efficiency, and finally introduce complex mechanisms according to actual scale. This is how a maintainable technical solution can be built over the long term.
