Architecture and Performance Optimization for a Multi-Category Product Catalog System
This article walks through the architecture design and performance optimization of a multi-category product catalog that combines deep navigation trees, heterogeneous attributes, and content-driven merchandising. It explains a three-layer data model (category, attribute schema, item), a read-write separation strategy that flattens filterable attributes into a search index with idempotent change events, layered retrieval and configurable ranking, cache key design and consistency tactics, content and catalog decoupling, observability and capacity protection, common pitfalls, and a phased rollout plan. Readers will get concrete schema examples, event structures, and practical trade-off guidance for building a catalog that stays consistent under heavy reads and frequent content updates.
1. Problem Background and Goals
The source material describes a typical product catalog page with multiple categories, multiple hierarchy levels, and strong merchandising intent: top-level entries are organized by audience and scenario, the middle level aggregates by category, and the bottom level breaks down into specific product types. Each category also carries its own copy and visual theme.
Abstracted into technical terms, this comes down to one sentence: the system must simultaneously serve three types of heterogeneous data — the navigation tree, the attribute system, and content assets — while maintaining consistency under high-concurrency reads and low-frequency writes.
Before writing any code, quantify the goals so the architecture does not drift later:
- Read-heavy, write-light: browsing and filtering requests typically far outnumber backend maintenance requests, with a read/write ratio of tens to one or higher.
- Deep hierarchy with uneven branches: few top-level nodes, a very large number of leaf nodes, and drastically different product counts under different categories.
- Heterogeneous attributes: attribute fields differ completely across categories and cannot be covered by a single wide table.
- Frequent content operations: copy, hero images, and theme colors are adjusted frequently by the operations side and must take effect within minutes.
- Tiered consistency requirements: price and inventory require strong consistency, while copy and ordering allow eventual consistency.
2. Catalog Data Modeling: Three Layers of Abstraction
The recommended approach is to split the catalog into three layers that communicate only through stable identifiers, avoiding coupling.
- Category layer: a tree structure with suggested fields
id,parent_id,path,level,sort_weight, andstatus. The materializedpath(for example1/12/135) is a highly cost-effective design: a single query retrieves the entire subtree. - Attribute schema layer: each category is bound to a set of attribute definitions covering the attribute identifier, data type, whether it is filterable, whether it participates in sorting, and the value source (enum or free text).
- Item layer: stores only common fields; category-specific fields go into an extensible structure (a JSON column or a separate key-value extension table), validated by the attribute schema layer.
A sample schema:
CREATE TABLE category (id BIGINT PRIMARY KEY,parent_id BIGINT NOT NULL,path VARCHAR(255) NOT NULL,level TINYINT NOT NULL,sort_weight INT NOT NULL DEFAULT 0,status TINYINT NOT NULL DEFAULT 1,KEY idx_parent (parent_id),KEY idx_path (path));CREATE TABLE item (id BIGINT PRIMARY KEY,category_id BIGINT NOT NULL,title VARCHAR(255) NOT NULL,attrs JSON NULL,updated_at DATETIME NOT NULL,KEY idx_cat_time (category_id, updated_at));
The key judgment here: do not let attributes expand infinitely in an EAV model, and do not hardcode a wide table. The former requires many self-joins to query; the latter requires a schema change every time a category is added. A JSON extension column combined with attribute-schema validation is the more balanced trade-off in current engineering practice.
3. Read-Write Separation for Dynamic Attributes
Heterogeneous attributes create an immediate challenge: filtering. Scanning the primary database on every filter request is unacceptable. The common approach is to build a derived structure optimized for retrieval:
- Write side: after an item changes, a change event is published through a message queue; the consumer flattens common fields and filterable attributes into the search index.
- Read side: filtering, sorting, and pagination are all handled on the search side; the primary database only serves detail queries and writes.
- Idempotency design: the consumer uses
item_id + versionas the idempotency key, where the version is an update timestamp or a monotonically increasing sequence, preventing out-of-order messages from overwriting newer data with stale data.
Change event structure (illustrative){"item_id": 10086,"category_path": "1/12/135","version": 1735689600000,"filterable": { "material": "leather", "color": "brown" },"sortable": { "heat": 980, "price": 3200 }}
4. Layered Implementation of Retrieval and Ranking
Catalog page ranking is rarely a single dimension; it is usually a composite of “operations weight + popularity + freshness.” The recommendation is to break ranking into configurable layered scoring instead of hardcoding the formula in application code:
- Base filtering: status, category subtree, sellable region.
- Hard ranking: pinned weight takes priority to keep operations in control.
- Soft ranking: popularity, conversion rate, and listing time are weighted; weights are externalized as configuration and support gradual rollout adjustments.
- Diversification rules: when the same category and brand appear consecutively beyond a threshold, apply a penalty to improve the browsing experience.
It is worth emphasizing that weight configurations must be versioned with a record of what took effect; otherwise, production behavior cannot be traced back, and the cost of diagnosing issues rises sharply.
5. Caching and Consistency
A catalog is classic “cacheable data,” but the cache objects must be distinguished:
- Category tree: changes very rarely, suitable for local caching with scheduled refresh, plus a manual invalidation entry point.
- Filtered result pages: use a combination of “category + filter conditions + sort + page number” as the cache key, with a short expiration to prevent long-tail combinations from growing without bound.
- Item details: use sidecar caching — update the data source first, then delete the cache — combined with delayed double deletion to reduce the probability of dirty data under concurrent reads.
Cache key design and penetration protection are equally important:
cache_key = "cat:list:" + category_path + ":" + hash(sorted(filters)) + ":" + page
For nonexistent categories or invalid filter combinations, validate parameter legality first before accessing the cache and storage, so invalid requests never reach the backend.
6. Linking Content Assets with the Catalog
In the source material, every category carries its own theme copy and visual tone. This suggests that content should not be hardcoded in the frontend; it should be bound to category nodes and published independently. The recommended approach:
- Attach content resource references (copy, images, theme identifier) to category nodes; store content independently in object storage, with the catalog side keeping only the reference address and version number.
- The frontend pulls by version number, combined with edge caching on a content delivery network, to achieve minute-level updates.
- Gradual rollout: new content first takes effect on a small-traffic subset of nodes; after observing error rates and conversion metrics, roll it out fully.
7. Observability and Capacity Protection
Three types of observability must be in place before launch; otherwise, production issues can only be guessed at:
- Logging service: record the category, filter conditions, latency, and result count of retrieval requests to help analyze long-tail queries.
- Monitoring and alerting: set threshold alerts for retrieval latency, cache hit rate, and message consumption backlog.
- Rate limiting and degradation: when pressure on the search side is too high, degrade to “return default ordering by category only” to keep the main path available.
8. Common Pitfalls
- Using a single wide table for all category attributes, causing frequent schema changes and making historical data hard to migrate.
- Hardcoding ranking formulas in business code, so every operations adjustment requires a release.
- Cache keys that omit sort and filter dimensions, causing dirty reads where filter conditions bleed into each other.
- No idempotency in message consumption, so data rolls back after network jitter.
- Monitoring only API success rates, not abnormal result counts (for example, a sudden spike in the proportion of zero-result responses).
9. Recommended Rollout Path
In the first phase, complete the modeling of the category tree and common item fields, and get detail queries working. In the second phase, introduce change events and the derived search structure, moving filtering and sorting to the search side. In the third phase, complete layered caching, gradual rollout, and the observability system. In the fourth phase, decouple content assets from categories to enable self-service publishing by operations. Following this order delivers usable production capability at every phase, rather than a single high-risk cutover at the end.
