NewsCrawler.org

Frequent Secrets Manager calls clogged DNS and metadata requests on an e-commerce site

Secrets Managerを呼びすぎたら、DNSまで詰まった話
Image: zenn.dev

After the company replaced its e-commerce login system this year, the app began fetching API keys and other secrets from AWS Secrets Manager at the start of each session. Some pages then stalled for between a few seconds and 20 seconds, and the web server's queue of waiting requests grew to 7 to 9 times normal on two days in a row. The logs showed no rate-limit errors. Instead, two problems occurred at the same time: connections to the IMDS[1] metadata service timed out, and DNS lookups took about 5 seconds. Both are link-local[2] traffic, which shares a limit of 1024 packets per second per network interface, and the counter for exceeding that limit rose from 900 to 2,588. Each Secrets Manager call also triggered about three metadata requests from the AWS SDK[3] plus DNS lookups, and retries multiplied the metadata requests about tenfold, to 770 per minute.

The author's fix is to cache secrets in the session and also in an encrypted database, with a one-hour expiry. The lock is taken only when the cache has expired, so requests do not queue up behind it. The author expects metadata requests to drop from 50 to 100 per minute to a few per hour, and Secrets Manager calls from 20 to 30 per minute to a few per hour. The change was not yet implemented at the time of writing, so these figures are design estimates that the author plans to check after release. The author also expects Secrets Manager API fees to fall by a few dollars a month.

The author lists three lessons. Side traffic that accompanies a call can hit a limit even when the call itself does not. Retries can make a slowdown much worse. A cache needs decisions about where it is stored, when it expires and how it is refreshed, not just the fact that it exists.

Read the original zenn.dev

Sources

  • Zenn JA

    Secrets Managerを呼びすぎたら、DNSまで詰まった話

    4 likes0 bookmarks2 comments

Published: First seen: Читать по-русски

Open as a page