mcpField
O
opensearch-personalize-caching-strategies

opensearch-personalize-caching-strategies

github.com/pproencaDevelopment218120 installsUpdated 11w ago
Repository

About opensearch-personalize-caching-strategies

A reference skill for designing and tuning caches in AWS marketplace search and recommendation services using OpenSearch and Personalize. It organizes guidance from cache decisions and key design through freshness, resilience, measurement, and tiering, with examples and cited sources.

Key features

  1. 01缓存收益与流量评估
  2. 02缓存键规范化与个性化边界
  3. 03策略、TTL 与失效设计
  4. 04并发未命中与故障防护
  5. 05命中率、延迟与成本观测
  6. 06负缓存及分层缓存

Use cases

  1. 01评估搜索或推荐接口是否适合缓存
  2. 02排查低命中率与键基数过高
  3. 03缓解 Personalize 限流和缓存重建风暴
  4. 04根据日志模拟缓存策略与 TTL

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/pproenca/dot-skills --skill opensearch-personalize-caching-strategies

After installing, type/opensearch-personalize-caching-strategiesin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

AGENTS.md
metadata.json
assets/templates/
_template.md
references/
_sections.md
decide-amplification-multiplier.md
decide-cache-roi-calculation.md
decide-cardinality-floor.md
decide-hot-key-distribution.md
decide-latency-budget.md
decide-personalize-quota-budget.md
decide-search-vs-personalize-asymmetry.md
key-bucket-numerical-ranges.md
key-canonicalize-query.md
key-locale-currency-explicit.md
key-segment-not-user.md
key-stable-hash-algorithm.md
key-strip-volatile-params.md
key-version-the-model.md
neg-bloom-filter-against-misses.md
neg-cache-empty-results.md
neg-cache-throttled-personalize.md
neg-poison-pill-detection.md
obs-cache-simulation-from-logs.md
obs-cost-attribution.md
obs-hit-rate-by-key-class.md
obs-key-cardinality-tracking.md
obs-latency-histograms-with-without.md
obs-stale-served-ratio.md
pers-anonymous-vs-logged-split.md
pers-cohort-precomputation.md

Details

From the project README

Marketplace-Research OpenSearch + Personalize Caching Best Practices

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?"

When to Apply

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".

The Caching Pipeline

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)

Rule Categories by Priority

PriorityCategoryImpactPrefixRules
1Decision & Cost CalculusCRITICALdecide-7
2Cache Key DesignCRITICALkey-7
3Personalisation BoundaryHIGHpers-6
4Strategies & Write PathsHIGHstrat-6
5TTL & FreshnessHIGHttl-6
6Stampede ProtectionHIGHstamp-5
7Observability & Empirical MeasurementHIGHobs-6
8Negative & Defensive CachingMEDIUM-HIGHneg-4
9Tiered & Edge CachingMEDIUM-HIGHtier-5

Quick Reference

1. Decision & Cost Calculus (CRITICAL)
2. Cache Key Design (CRITICAL)
3. Personalisation Boundary (HIGH)
4. Strategies & Write Paths (HIGH)
5. TTL & Freshness (HIGH)
6. Stampede Protection (HIGH)
7. Observability & Empirical Measurement (HIGH)
8. Negative & Defensive Caching (MEDIUM-HIGH)
9. Tiered & Edge Caching (MEDIUM-HIGH)

How to Use

For 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.

Related Skills

Reference Files

FileDescription
references/_sections.mdCategory definitions and ordering by cascade impact
AGENTS.mdCompact TOC navigation (auto-built; do not edit by hand)
assets/templates/_template.mdTemplate for authoring new rules
metadata.jsonVersion and authoritative reference URLs

Comments

Markdown supported