cost agent's pricing lookup loop hit LimitExceededException - it called the AWS Pricing API once per instance instead...
Fixes a cost agent that hits LimitExceededException on the AWS Pricing API by calling it once per instance. Use when rightsizing runs die throttled or CloudTrail shows hundreds of GetProducts calls per run. It batches lookups by unique instance type and region, caches prices with a TTL, and adds retry with backoff. Key trigger: per-instance pricing calls in a loop.
TL;DR: Cache pricing by instance type and region, and batch lookups so the agent calls the Pricing API once per unique instance type instead of once per instance. The AWS Pricing API has a low rate limit and per-instance calls blow through it fast. One cached batch lookup per instance family usually cuts API calls by 90 percent or more.
cost agent's pricing lookup loop hit LimitExceededException - it called the AWS Pricing API once per instance instead of batching- Confirm the failure pattern in the agent's logs. Count how many pricing calls it makes per run and compare against the number of distinct instance types. Expected: calls per run roughly equal instance count, not instance-type count.
- Replace per-instance calls with one GetProducts call per unique combination of instance type, region, and operating system. Build the filter list once, then join results back to instances in memory. Expected: API calls drop from N instances to a handful of unique tuples.
- Cache the results. Pricing changes slowly, so store fetched prices in the agent's datastore or a local file with a 24-hour TTL. Expected: later runs make zero pricing API calls unless the cache expired.
- Add retry with exponential backoff and jitter around the remaining calls. On LimitExceededException, wait and retry instead of crashing the run. Expected: occasional throttling no longer kills the whole rightsizing job.
Use this when
- Your cost agent calls the AWS Pricing API in a loop, once per instance or volume
- Rightsizing runs die with LimitExceededException from the pricing service
- You see hundreds of GetProducts calls in CloudTrail for a single agent run
- Pricing lookups are the slowest part of the cost analysis
Not for this skill when
- The throttling is on Cost Explorer (ce:GetCostAndUsage) rather than the Pricing API
- You need real-time spot prices, which come from a different API with different limits
- The agent already batches and caches but still throttles - look at concurrency instead
Variant phrasings
- aws pricing api rate limit in cost optimization script
- GetProducts LimitExceededException looping over instances
- cost agent throttled on price list api
- too many requests to aws pricing api from rightsizing job
Why it happens
The AWS Price List API is built for bulk price discovery, not per-resource lookups. Its rate limit is much lower than EC2 or Cost Explorer, and agents written in the obvious way call GetProducts inside the per-instance loop because that is the simplest code shape. The fix is architectural: fetch once per price dimension, cache, and join in memory.
Edge cases
- Spot pricing is not in the Price List API. Do not try to batch spot lookups this way; use the spot price history API instead.
- Prices vary by region, OS, tenancy, and term. Your cache key must include all of these or the agent will apply us-east-1 Linux prices to Windows instances elsewhere.
- Savings plan and reserved instance effective rates are not list prices. Batching fixes the throttling, not the math - check the commitment math separately.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_qRQl1oEQc2jQ2cHe0oZVGg
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.