Skip to content

Commit

Permalink
Merge pull request #470 from go-graphite/carbonserer/quota-friendly-f…
Browse files Browse the repository at this point in the history
…ile-list-cache

carbonserver: introduce file list cache v2
  • Loading branch information
bom-d-van authored Jun 9, 2022
2 parents 4f781db + 093f6a9 commit 1182c9c
Show file tree
Hide file tree
Showing 11 changed files with 717 additions and 176 deletions.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,26 @@ trie-index = false
# most of the indexing time if it contains a high number of metrics (10
# - 40 millions). go-carbon only reads the cached file list once after
# reboot and the cache result is updated after every scan. (EXPERIMENTAL)
file-list-cache = ""
#
# file-list-cache = "/var/lib/carbon/carbonserver-file-list-cache.bin"

# Supported FLC (file list cache) version values are: 2, 1 (default value is 1
# for backward compatibility).
#
# File list cache v2 is is more advanced of file list cache for go-carbon, with
# good quota support during restarts (by keeping physical, logical sizes, metric
# creation time in the cache). For more details, see carbonserver/flc.go.
#
# V2 file is no longer a plain text file compressed with gzip, but a semi-binary
# file. For reading flc v2 cache file, use go-carbon with flag -print-file-list-cache:
#
# go-carbon -print-file-list-cache /var/lib/carbon/carbonserver-file-list-cache.bin
#
# For upgrade or downgrade to v2 or v1, you can just update the config,
# go-carbon would transparently detect the existing cache file on restart. No
# manual deletion needed.
#
# file-list-cache-version = 2

# Enable concurrently building index without maintaining a new copy
# index structure. More memory efficient.
Expand Down
1 change: 1 addition & 0 deletions carbon/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ func (app *App) Start(version string) (err error) {
carbonserver.SetTrieIndex(conf.Carbonserver.TrieIndex)
carbonserver.SetConcurrentIndex(conf.Carbonserver.ConcurrentIndex)
carbonserver.SetFileListCache(conf.Carbonserver.FileListCache)
carbonserver.SetFileListCacheVersion(conf.Carbonserver.FileListCacheVersion)
carbonserver.SetInternalStatsDir(conf.Carbonserver.InternalStatsDir)
carbonserver.SetPercentiles(conf.Carbonserver.Percentiles)
// carbonserver.SetQueryTimeout(conf.Carbonserver.QueryTimeout.Value())
Expand Down
25 changes: 14 additions & 11 deletions carbon/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,12 @@ type carbonserverConfig struct {
MaxMetricsGlobbed int `toml:"max-metrics-globbed"`
MaxMetricsRendered int `toml:"max-metrics-rendered"`

TrieIndex bool `toml:"trie-index"`
ConcurrentIndex bool `toml:"concurrent-index"`
RealtimeIndex int `toml:"realtime-index"`
FileListCache string `toml:"file-list-cache"`
TrieIndex bool `toml:"trie-index"`
ConcurrentIndex bool `toml:"concurrent-index"`
RealtimeIndex int `toml:"realtime-index"`

FileListCache string `toml:"file-list-cache"`
FileListCacheVersion int `toml:"file-list-cache-version"`

QuotaUsageReportFrequency *Duration `toml:"quota-usage-report-frequency"`

Expand Down Expand Up @@ -259,13 +261,14 @@ func NewConfig() *Config {
WriteTimeout: &Duration{
Duration: 60 * time.Second,
},
QueryCacheEnabled: true,
QueryCacheSizeMB: 0,
FindCacheEnabled: true,
TrigramIndex: true,
CacheScan: false,
MaxMetricsGlobbed: 10_000_000,
MaxMetricsRendered: 1_000_000,
QueryCacheEnabled: true,
QueryCacheSizeMB: 0,
FindCacheEnabled: true,
TrigramIndex: true,
CacheScan: false,
MaxMetricsGlobbed: 10_000_000,
MaxMetricsRendered: 1_000_000,
FileListCacheVersion: 1, // see carbonserver/flc.go
},
Carbonlink: carbonlinkConfig{
Listen: "127.0.0.1:7002",
Expand Down
Loading

0 comments on commit 1182c9c

Please sign in to comment.