cache: Per-client fair-share bandwidth on table uplink
This commit is contained in:
+12
@@ -22,6 +22,8 @@ var (
|
||||
|
||||
maxConcurrentRequests int64
|
||||
maxRequestsPerClient int64
|
||||
uplinkBandwidth string
|
||||
maxBytesPerClientPerSec int64
|
||||
)
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
@@ -107,6 +109,12 @@ var rootCmd = &cobra.Command{
|
||||
if maxRequestsPerClient > 0 {
|
||||
finalMaxRequestsPerClient = maxRequestsPerClient
|
||||
}
|
||||
if uplinkBandwidth != "" {
|
||||
cfg.UplinkBandwidth = uplinkBandwidth
|
||||
}
|
||||
if maxBytesPerClientPerSec > 0 {
|
||||
cfg.MaxBytesPerClientPerSec = maxBytesPerClientPerSec
|
||||
}
|
||||
|
||||
// Validate after loading and applying CLI overrides (fail fast, do not create default on validate error)
|
||||
if err := cfg.Validate(); err != nil {
|
||||
@@ -130,6 +138,8 @@ var rootCmd = &cobra.Command{
|
||||
cfg.MaxObjectSize,
|
||||
cfg.TrustedProxies,
|
||||
cfg.Cache.NegativeTTL,
|
||||
cfg.UplinkBandwidth,
|
||||
cfg.MaxBytesPerClientPerSec,
|
||||
)
|
||||
if err != nil {
|
||||
logger.Logger.Error().
|
||||
@@ -170,4 +180,6 @@ func init() {
|
||||
|
||||
rootCmd.Flags().Int64Var(&maxConcurrentRequests, "max-concurrent-requests", 0, "Maximum concurrent requests (0 = use config file value)")
|
||||
rootCmd.Flags().Int64Var(&maxRequestsPerClient, "max-requests-per-client", 0, "Maximum concurrent requests per client IP (0 = use config file value)")
|
||||
rootCmd.Flags().StringVar(&uplinkBandwidth, "uplink-bandwidth", "", "Table uplink bandwidth bytes/sec human size e.g. 10MB (empty = use config; 0 disables)")
|
||||
rootCmd.Flags().Int64Var(&maxBytesPerClientPerSec, "max-bytes-per-client-per-sec", 0, "Absolute per-client bytes/sec cap (0 = use config file value)")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user