Provides caching strategies for AWS OpenSearch and Personalize — covering ROI, key design, TTL, stampede protection, and observability. Activates on cache hit rate, throttling, or stampede.
How this skill is triggered — by the user, by Claude, or both
Slash command
/pproenca-dot-skills-1:opensearch-personalize-caching-strategiesThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
A reference distillation of caching strategies for two-sided marketplaces running AWS OpenSearch (search) and AWS Personalize (recommendations behind a microservice). Contains **52 rules across 9 categories**, ordered by cascade effect — from the upstream decision of *whether* to cache, through key design, personalisation boundary, strategy selection, TTL design, stampede protection, observabil...
A reference distillation of caching strategies for two-sided marketplaces running AWS OpenSearch (search) and AWS Personalize (recommendations behind a microservice). Contains 52 rules across 9 categories, ordered by cascade effect — from the upstream decision of whether to cache, through key design, personalisation boundary, strategy selection, TTL design, stampede protection, observability, and the lower-cascade categories of negative caching and tier composition. Each rule explains the WHY (the cost, latency, or correctness mechanism), shows incorrect-vs-correct code (TypeScript/Node for the microservice layer, Python for batch and analytics, OpenSearch JSON for OS-specific queries, YAML for CDN/Kubernetes), and cites the canonical source — AWS Personalize/OpenSearch/ElastiCache documentation, the XFetch paper (Vattani et al. VLDB 2015), RFC 5861 (stale-while-revalidate), and the engineering blogs of cache infrastructure teams (Netflix EVCache, Pinterest Cachelib, Twitter Twemcache, Cloudflare).
This is the complement to opensearch-function-scoring-algorithms — that skill answers "what should the ranking compute?", this skill answers "how do you scale it to production traffic without burning down OpenSearch or Personalize?"
Reach for this skill when:
The rules apply to any AWS-based marketplace with OpenSearch and Personalize fronted by an application microservice, regardless of vertical — accommodation, food delivery, fashion, services, jobs, secondhand goods, real estate. Triggers include "cache hit rate", "cache miss storm", "Personalize throttling", "Personalize cost", "multi-recommender page", "cohort caching", "single-flight", "stale-while-revalidate", "XFetch", "OpenSearch slow queries", "ElastiCache sizing", "CloudFront search caching", "Bloom filter cache penetration", and "thundering herd".
Categories are derived from the request-time caching pipeline. Earlier stages cascade: a wrong "should we cache?" decision wastes everything below; un-canonicalised keys cap hit rate at a fraction of the achievable ceiling; without observability you can't tell whether any of the rules helped.
Request → [1] Decide → [2] Key construction → [3] Personalisation boundary
→ [4] Strategy (read/write path) → [5] TTL/freshness → [6] Stampede protection
→ [8] Negative/defensive → [9] Tier composition (L1/L2/CDN/OS-internal) → Response
↑
[7] Observability (meta-layer applied to all stages:
hit rate by key class, latency-with-and-without,
cost-per-1k, cardinality, staleness, log-replay)
| Priority | Category | Impact | Prefix | Rules |
|---|---|---|---|---|
| 1 | Decision & Cost Calculus | CRITICAL | decide- | 7 |
| 2 | Cache Key Design | CRITICAL | key- | 7 |
| 3 | Personalisation Boundary | HIGH | pers- | 6 |
| 4 | Strategies & Write Paths | HIGH | strat- | 6 |
| 5 | TTL & Freshness | HIGH | ttl- | 6 |
| 6 | Stampede Protection | HIGH | stamp- | 5 |
| 7 | Observability & Empirical Measurement | HIGH | obs- | 6 |
| 8 | Negative & Defensive Caching | MEDIUM-HIGH | neg- | 4 |
| 9 | Tiered & Edge Caching | MEDIUM-HIGH | tier- | 5 |
decide-cache-roi-calculation — Compute Cache ROI Before Adding the Cachedecide-cardinality-floor — Skip Caching When Traffic Distribution is Flatdecide-personalize-quota-budget — Model Personalize TPS Budget Before Choosing a Cache Strategydecide-latency-budget — Cache Only When Origin p99 Exceeds the Latency Budgetdecide-amplification-multiplier — Account for Multi-Recommender Page Amplificationdecide-hot-key-distribution — Profile Traffic Distribution Before Sizing the Cachedecide-search-vs-personalize-asymmetry — Cache Candidate Sets for Search, Full Payloads for Personalizekey-canonicalize-query — Canonicalise Queries Before Hashingkey-segment-not-user — Key Recommenders by Cohort When Users Outnumber Cohortskey-version-the-model — Include the Personalize Solution Version in the Cache Keykey-locale-currency-explicit — Make Locale, Currency, and Timezone Explicit in the Keykey-strip-volatile-params — Strip Volatile and Tracking Params Before Hashingkey-bucket-numerical-ranges — Bucket Continuous Filters Before Hashingkey-stable-hash-algorithm — Use SHA-256 over MD5 for High-Cardinality Keyspers-cohort-precomputation — Precompute Recommendations Per Cohort Offlinepers-anonymous-vs-logged-split — Route Anonymous Traffic to Global Cache, Logged-in to Cohort Cachepers-cold-start-cache-priority — Serve Cold-Start Users From Popularity Cache, Skip Personalizepers-recommender-fan-out-coalescing — Coalesce Multi-Recommender Fan-Out Into Batched Callspers-shared-candidates-private-ranking — Cache Retrieval Candidates Globally, Re-Rank Per-User From Cachepers-session-vector-write-through — Maintain Session Vectors in Cache with Write-Through on Every Eventstrat-cache-aside-default — Use Cache-Aside as the Default Strategy for Read-Heavy Pathsstrat-refresh-ahead-hot-keys — Use Refresh-Ahead Only for the Top 1% of Hot Keysstrat-write-through-mutations — Use Write-Through When User Mutations Are Immediately Re-Readstrat-precompute-batch — Precompute the Popular Fraction with Batch Jobsstrat-tiered-promotion — Promote to L1 In-Process Cache on L2 Hitstrat-async-warm-up — Async Warm-Up After Deploy, Restart, or Model Retrainttl-by-content-volatility — Set TTL From Content Volatility, Not Engineering Conveniencettl-soft-and-hard — Separate Soft TTL (Async Refresh) from Hard TTL (Sync Miss)ttl-jitter-to-prevent-thundering — Add Random Jitter to TTL to Prevent Synchronized Expiryttl-personalize-solution-version — Pin TTL to Personalize Solution Version, Not Wall Clockttl-event-driven-invalidation — Pair TTL with Event-Driven Invalidation for Critical Freshnessttl-bound-by-staleness-tolerance — Bound TTL by Product Staleness Tolerance, Not the Defaultstamp-coalesce-concurrent-misses — Coalesce Concurrent Misses Into a Single Origin Callstamp-probabilistic-early-expiration — Use XFetch Probabilistic Early Expiration for Hot Keysstamp-serve-stale-on-rebuild — Serve Stale While Refresh Is In Flightstamp-circuit-breaker-on-origin-error — Trip the Circuit Breaker on Origin Errors; Fall Back to Stalestamp-distributed-lock-rebuild — Use a Distributed Lock to Coordinate Cross-Instance Cache Rebuildsobs-hit-rate-by-key-class — Track Hit Rate by Key Class, Never Aggregate Onlyobs-latency-histograms-with-without — Measure Latency Histograms With-Hit and With-Miss Separatelyobs-cost-attribution — Attribute Cost Per Thousand Requests With and Without Cacheobs-key-cardinality-tracking — Sample Key Cardinality Daily; Alert on Explosionobs-stale-served-ratio — Measure Stale-Served Ratio to Validate TTL Choiceobs-cache-simulation-from-logs — Replay Production Logs Through a Cache Simulator Before Changing TTL or Strategyneg-cache-empty-results — Cache Empty Search Results With a Short TTLneg-cache-throttled-personalize — Serve Last-Known-Good When Personalize Throttlesneg-bloom-filter-against-misses — Use a Bloom Filter to Block High-Cardinality Miss Stormsneg-poison-pill-detection — Checksum Cache Entries to Detect and Reject Poisoned Writestier-l1-in-process — Use In-Process LRU as L1 for Sub-Millisecond Readstier-l2-elasticache-redis — Size L2 ElastiCache to the Cross-Instance Working Settier-cdn-for-anonymous — Use CDN for Anonymous Traffic; Bypass for Cookiestier-opensearch-request-cache — Enable OpenSearch Request Cache for Aggregation-Heavy Queriestier-opensearch-filter-context — Put Reusable Predicates in Filter Context for Segment-Level CachingFor a focused question ("should I cache this?", "why is my hit rate low?", "how do I survive Personalize throttling?"), jump directly to the relevant rule — each is self-contained with the WHY, code, and citation.
For a full caching-design review of a new or struggling surface, work the categories top-to-bottom. The cascade is real: a wrong decide-cache-roi-calculation wastes engineering effort on a cache that doesn't pay; a leaky key-canonicalize-query caps the achievable hit rate; a missing pers-cohort-precomputation keeps Personalize bills proportional to MAU. Stampede and observability are mandatory once hit rate exceeds 90% — the 10% miss in a thundering herd kills the origin, and without per-class hit-rate dashboards you can't tell.
For tuning an existing cache empirically, start with obs-cache-simulation-from-logs (replay your logs through what-if configs) and pair with obs-hit-rate-by-key-class, obs-cost-attribution, and obs-stale-served-ratio for the dashboards. The trio answers: is the cache doing its job, what does it cost, and are users seeing stale data?
For the multi-recommender homepage problem specifically (the most common Personalize cost-explosion pattern), the priority order is: decide-amplification-multiplier → pers-cohort-precomputation → pers-recommender-fan-out-coalescing → pers-anonymous-vs-logged-split. These four typically cut Personalize spend by 70-90% on consumer marketplaces.
For the "Personalize is throttling under load" incident, the priority is: stamp-circuit-breaker-on-origin-error → neg-cache-throttled-personalize → decide-personalize-quota-budget. The first two stabilise the user-facing impact; the third right-sizes minProvisionedTPS so it doesn't happen again.
For sibling-skill cross-reference, see opensearch-function-scoring-algorithms — that skill covers what to compute in OpenSearch (function_score, kNN, RRF, rank_feature, decay, LTR, MMR, evaluation). This skill covers how to cache it so the cluster survives production traffic.
Read section definitions for the cascade-impact rationale, or the rule template when adding a new rule.
opensearch-function-scoring-algorithms — Research-backed ranking, retrieval, and evaluation rules for OpenSearch. The "what to compute"; this skill is the "how to scale it."| File | Description |
|---|---|
| references/_sections.md | Category definitions and ordering by cascade impact |
| AGENTS.md | Compact TOC navigation (auto-built; do not edit by hand) |
| assets/templates/_template.md | Template for authoring new rules |
| metadata.json | Version and authoritative reference URLs |
npx claudepluginhub joshuarweaver/cascade-code-general-misc-1 --plugin pproenca-dot-skills-1Guides caching strategy decisions: read/write patterns, eviction policies, and when to cache or not. Activated by cache-related terms or read-heavy design discussions.
Deploys production recommendation systems with feature stores, caching, A/B testing, and monitoring. For personalization APIs, low-latency serving, cache invalidation, experiment tracking, quality metrics.
Designs and debugs personalisation and recommendation systems for two-sided trust marketplaces using AWS Personalize. Covers event tracking, schema design, cold start, bias control, and observability.