# Cut RPC cost & latency > Source: https://docs.erpc.cloud/use-cases/cut-costs-and-latency > Serve repeated questions from cache, deduplicate identical requests, and stop paying providers for the same answer twice. > Format: machine-readable markdown export of the docs page above. > All collapsible AI sections are inlined and fully expanded. # Cut RPC cost & latency Most blockchain data never changes — a block from last year is the same block forever. eRPC caches those answers permanently, merges identical in-flight requests into one, and races a backup upstream only when it actually helps. Teams typically watch their provider bill drop while p99 latency gets faster: cached answers return in microseconds and never count against a rate limit. - **[EVM JSON-RPC cache](/config/database/evm-json-rpc-cache.llms.txt)** — Finality-aware caching: permanent for old blocks, careful for fresh ones. - **[Cache drivers](/config/database/drivers.llms.txt)** — Memory for speed, Redis/Postgres/DynamoDB for shared permanence. - **[Batching & multiplexing](/operation/batch.llms.txt)** — A thousand identical requests become one upstream call. - **[Hedge](/config/failsafe/hedge.llms.txt)** — Pay for a second request only when the first is being slow. - **[Shared state](/config/database/shared-state.llms.txt)** — A fleet of eRPC pods shares one view of chain progress. All of the above in one place — illustrative, not a tuned production config: **Config path:** `(root)` **YAML — `erpc.yaml`:** ```yaml database: evmJsonRpcCache: # two cache tiers: in-process for speed, redis for shared permanence connectors: - id: hot driver: memory - id: cold driver: redis redis: addr: redis-cache:6379 # finalized data is immutable: cache it forever; fresh data gets a short TTL policies: - connector: hot finality: finalized - connector: cold finality: finalized - connector: hot finality: unfinalized ttl: 5s # one shared view of chain tip across all pods sharedState: connector: id: redis-shared driver: redis redis: addr: redis-cache:6379 projects: - id: main networkDefaults: failsafe: - matchMethod: "*" # pay for a 2nd request only on slow tails hedge: delay: { quantile: 0.7, min: 100ms, max: 2s } maxCount: 1 upstreamDefaults: # pack outbound calls into JSON-RPC batches jsonRpc: supportsBatch: true batchMaxSize: 10 batchMaxWait: 50ms # In-flight multiplexing (identical concurrent requests → one call) is automatic. ``` **TypeScript — `erpc.ts`:** ```typescript database: { evmJsonRpcCache: { // two cache tiers: in-process for speed, redis for shared permanence connectors: [ { id: "hot", driver: "memory" }, { id: "cold", driver: "redis", redis: { addr: "redis-cache:6379" } }, ], // finalized data is immutable: cache forever; fresh data gets a short TTL policies: [ { connector: "hot", finality: "finalized" }, { connector: "cold", finality: "finalized" }, { connector: "hot", finality: "unfinalized", ttl: "5s" }, ], }, // one shared view of chain tip across all pods sharedState: { connector: { id: "redis-shared", driver: "redis", redis: { addr: "redis-cache:6379" } }, }, }, projects: [{ id: "main", networkDefaults: { failsafe: [{ matchMethod: "*", // pay for a 2nd request only on slow tails hedge: { delay: { quantile: 0.7, min: "100ms", max: "2s" }, maxCount: 1 }, }], }, upstreamDefaults: { // pack outbound calls into JSON-RPC batches jsonRpc: { supportsBatch: true, batchMaxSize: 10, batchMaxWait: "50ms" }, }, }] ``` ## Agent reference Copy one of these prompts into your AI agent session (Claude Code, Cursor, …) — each one points the agent at this page's machine-readable reference so it can do the work correctly: **Prompt Example #1: cut my RPC provider bill with eRPC caching** ```text I want to reduce the number of paid RPC calls my app makes by caching blockchain data in eRPC. Set up a two-tier cache (memory + Redis) in my eRPC config with finality-aware TTLs so finalized data is cached forever and fresh data expires quickly. Read the reference and follow the child-page links inside it: https://docs.erpc.cloud/use-cases/cut-costs-and-latency.llms.txt ``` **Prompt Example #2: reduce p99 latency with caching and hedge together** ```text I want to push p99 RPC latency as low as possible. Review my eRPC config and configure eRPC's cache layer and hedge feature together so cached answers return in microseconds and slow uncached calls are raced against a backup upstream. Reference: https://docs.erpc.cloud/use-cases/cut-costs-and-latency.llms.txt ``` **Prompt Example #3: deduplicate identical in-flight requests under high concurrency** ```text Under high concurrency my backend fires hundreds of identical eth_blockNumber and eth_getBlockByNumber calls simultaneously. Configure eRPC's multiplexing and batching in my eRPC config so those collapse to a single upstream call. Reference: https://docs.erpc.cloud/use-cases/cut-costs-and-latency.llms.txt ``` --- ### Cut costs — agent starting points This page sells the outcome; implementation lives in the feature pages. Fetch their machine-readable companions: - [EVM JSON-RPC cache](/config/database/evm-json-rpc-cache.llms.txt) — policy matching, finality semantics, TTLs, freshness gating, skip-cache directives. - [Cache drivers](/config/database/drivers.llms.txt) — every connector's config, TTL behavior, and operational footguns. - [Batching & multiplexing](/operation/batch.llms.txt) — inbound JSON-RPC batches, outbound upstream batching, in-flight dedup rules and exclusions. - [Shared state](/config/database/shared-state.llms.txt) — what's shared, pubsub propagation, clusterKey. - [Hedge](/config/failsafe/hedge.llms.txt) — quantile-based delays so hedging only fires on slow tails. Cost-relevant interactions an agent should weigh: cache hits skip rate-limit budgets and selection entirely; the multiplexer dedupes only identical (network, method, params) requests; finality classification decides whether a response is cached forever, with TTL, or gated on connector freshness. Field-level tables live in each page's agent section. --- ## Navigation (machine-readable surface) - Up: [All pages index](https://docs.erpc.cloud/llms.txt) - Root index of every page: [llms.txt](https://docs.erpc.cloud/llms.txt) · everything in one file: [llms-full.txt](https://docs.erpc.cloud/llms-full.txt) ### Sibling pages - [How eRPC works](https://docs.erpc.cloud/use-cases/how-it-works.llms.txt) — Every JSON-RPC call travels a battle-tested pipeline — auth, smart caching, parallel hedging, multi-upstream consensus — and arrives with full diagnostic headers. Zero glue code required. - [Lock it down](https://docs.erpc.cloud/use-cases/lock-it-down.llms.txt) — Keys, JWTs, sign-in with Ethereum, per-user rate limits — your RPC endpoint stops being a free-for-all. - [Scale chains & providers](https://docs.erpc.cloud/use-cases/scale-chains-and-providers.llms.txt) — One config line per provider, every chain they support — and the best upstream wins each request. - [See everything](https://docs.erpc.cloud/use-cases/see-everything.llms.txt) — Per-request metrics, traces, and honest healthchecks — know about problems before your users do. - [Survive provider outages](https://docs.erpc.cloud/use-cases/survive-provider-outages.llms.txt) — Keep serving traffic when an RPC provider slows down, rate-limits you, or disappears entirely. - [Trust the data](https://docs.erpc.cloud/use-cases/trust-the-data.llms.txt) — Don't let one misbehaving node feed your app a wrong answer — verify, cross-check, and enforce integrity automatically.