Counter Tracker Service for Cache Stampede Prevention

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

In large-scale cloud-based computer systems, concurrent access to cached data objects can lead to a 'stampede' scenario where multiple requests attempt to reload the same data from the database simultaneously, wasting resources and causing long wait times due to the lack of efficient cache management and invalidation strategies.

Innovation Solution

Implementing a distributed cache service platform with asynchronous and synchronous cache refresh strategies, including a distributed soft lock mechanism and extended TTL (time-to-live) periods, to manage cache invalidation and rebuilding, ensuring only one thread reloads data and minimizing database access, while using multiple cache levels and counter tracker services to optimize resource usage.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Productivity

If data objects are cached to minimize direct database accesses, then database access efficiency is improved, but concurrent reload attempts cause resource wastage and long wait times

Engineering Contradiction:
Improvedatabase access efficiencyVSAvoidresource wastage
Core Design Contradiction:
ProductivityVSLoss of energy

Solution Approach 1:

The system performs preliminary actions by checking cache validity and pre-acquiring locks before attempting data reload. The soft lock mechanism is acquired in advance to prevent concurrent reload attempts, and the system checks whether data objects are already present in cache before initiating database access, thereby avoiding unnecessary resource consumption.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

A soft lock mechanism is introduced as an intermediary to coordinate concurrent access to cached data objects. The lock acts as a mediator that allows one thread to proceed with data reload while blocking other concurrent attempts, thereby preventing the stampede scenario without requiring heavy-weight distributed locking mechanisms.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Reliability

If multiple threads concurrently reload data objects from database to cache, then cache availability is improved, but network and database resources are wasted

Engineering Contradiction:
Improvecache availabilityVSAvoidnetwork and database resources
Core Design Contradiction:
ReliabilityVSQuantity of substance

Solution Approach 1:

The system checks cache availability and acquires soft locks before initiating data reload operations. This preliminary validation ensures that reload operations are only performed when necessary and that only one thread proceeds with the actual database access, preventing redundant network and database resource consumption.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The system implements a grace period that extends beyond the normal TTL expiration time. During this grace period, stale data may still be served to maintain cache availability, while a background thread performs incremental cache rebuilding. This partial action approach maintains availability without requiring immediate full cache reloads.

Inventive Principle:
Principle #16Partial or excessive action

3Loss of energy

If cache TTL is extended to reduce reload frequency, then resource usage is improved, but data freshness may be compromised

Engineering Contradiction:
Improveresource usageVSAvoiddata freshness
Core Design Contradiction:
Loss of energyVSLoss of information

Solution Approach 1:

The system implements a grace period that extends beyond the normal TTL expiration time. During this grace period, the cache retains and serves data even after TTL expiration, reducing the frequency of reload operations and resource usage. The grace period acts as a buffer that allows slight data staleness in exchange for reduced resource consumption.

Inventive Principle:
Principle #16Partial or excessive action

Solution Approach 2:

The system performs preliminary checks to determine whether cached data is still valid or can be served during the grace period. Before serving stale data, the system checks whether the data object has been modified in the database, and only serves stale data when it is confirmed to be up-to-date, thereby maintaining data freshness when possible.

Inventive Principle:
Principle #10Preliminary action

Data Source

PatentUS10824559B2Counter tracker service
Publication Date: 2020.11.03 SALESFORCE INC
  • US10824559B2 patent drawing
  • US10824559B2 patent drawing
  • US10824559B2 patent drawing

AI summary

A read request for a counter designated to be only cached in a global cache is received. The counter is excluded from being persisted in and retrieved from one or more primary data sources It is determined whether the counter has already been created in the global cache. If the counter has already been created in the global cache, the counter is created in the global cache with an initial counter value while continually excluding the counter from being persisted in and retrieved from the one or more primary data sources. The counter is cached with a time-to-live (TTL) time period. The time-to-live time period is to be renewed on each subsequent read request of the counter. The counter is temporally stored in the data object cache until the TTL time period lapses.