Skip to content

Cache FileSecret reads - #954

Open
prymitive wants to merge 1 commit into
prometheus:mainfrom
prymitive:cache
Open

Cache FileSecret reads#954
prymitive wants to merge 1 commit into
prometheus:mainfrom
prymitive:cache

Conversation

@prymitive

Copy link
Copy Markdown

FileSecret reads files on every request, which means that if I configure a scrape job with:

tls_config:
  ca_file: ca.pem
  cert_file: cert.pem
  key_file: key.pem

All three files will be read using FileSecret every time a scrape starts for that target. With 1k targets and 1m scrape interval this means 50 file reads per second (1000 targets * 3 files / 60s).
File reads require a blocking syscall so having to re-read files all the time isn't ideal on busy instances with a lot of targets. These files are normally small and reads are fast, but the overhead is still there.

Make FileSecret cache file reads, for 1m by default, configurable via cache_ttl YAML key.

FileSecret reads files on every request, which means that if I configure a scrape job with:

```yaml
tls_config:
  ca_file: ca.pem
  cert_file: cert.pem
  key_file: key.pem
```

All three files will be read using FileSecret every time a scrape starts for that target.
With 1k targets and 1m scrape interval this means 50 file reads per second
(1000 targets * 3 files / 60s).
File reads require a blocking syscall so having to re-read files all the time isn't ideal on busy instances with a lot of targets.
These files are normally small and reads are fast, but the overhead is still there.

Make FileSecret cache file reads, for 1m by default, configurable via cache_ttl YAML key.

Signed-off-by: Lukasz Mierzwa <lukasz@cloudflare.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant