*: add flags to setup backend related config

release-3.4
Xiang Li 2018-11-26 15:50:26 -08:00
parent 6c649de36e
commit 3faed211e5
7 changed files with 40 additions and 1 deletions

View File

@ -82,6 +82,16 @@ To start etcd automatically using custom settings at startup in Linux, using a [
+ default: 0 + default: 0
+ env variable: ETCD_QUOTA_BACKEND_BYTES + env variable: ETCD_QUOTA_BACKEND_BYTES
### --backend-batch-limit
+ BackendBatchLimit is the maximum operations before commit the backend transaction.
+ default: 0
+ env variable: ETCD_BACKEND_BATCH_LIMIT
### --backend-batch-interval
+ BackendBatchInterval is the maximum time before commit the backend transaction.
+ default: 0
+ env variable: ETCD_BACKEND_BATCH_INTERVAL
### --max-txn-ops ### --max-txn-ops
+ Maximum number of operations permitted in a transaction. + Maximum number of operations permitted in a transaction.
+ default: 128 + default: 128

View File

@ -165,6 +165,10 @@ type Config struct {
// See https://github.com/etcd-io/etcd/issues/9333 for more detail. // See https://github.com/etcd-io/etcd/issues/9333 for more detail.
InitialElectionTickAdvance bool `json:"initial-election-tick-advance"` InitialElectionTickAdvance bool `json:"initial-election-tick-advance"`
// BackendBatchInterval is the maximum time before commit the backend transaction.
BackendBatchInterval time.Duration `json:"backend-batch-interval"`
// BackendBatchLimit is the maximum operations before commit the backend transaction.
BackendBatchLimit int `json:"backend-batch-limit"`
QuotaBackendBytes int64 `json:"quota-backend-bytes"` QuotaBackendBytes int64 `json:"quota-backend-bytes"`
MaxTxnOps uint `json:"max-txn-ops"` MaxTxnOps uint `json:"max-txn-ops"`
MaxRequestBytes uint `json:"max-request-bytes"` MaxRequestBytes uint `json:"max-request-bytes"`

View File

@ -43,7 +43,7 @@ import (
"go.etcd.io/etcd/version" "go.etcd.io/etcd/version"
"github.com/coreos/pkg/capnslog" "github.com/coreos/pkg/capnslog"
"github.com/grpc-ecosystem/go-grpc-prometheus" grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
"github.com/soheilhy/cmux" "github.com/soheilhy/cmux"
"go.uber.org/zap" "go.uber.org/zap"
"google.golang.org/grpc" "google.golang.org/grpc"
@ -181,6 +181,8 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) {
AutoCompactionRetention: autoCompactionRetention, AutoCompactionRetention: autoCompactionRetention,
AutoCompactionMode: cfg.AutoCompactionMode, AutoCompactionMode: cfg.AutoCompactionMode,
QuotaBackendBytes: cfg.QuotaBackendBytes, QuotaBackendBytes: cfg.QuotaBackendBytes,
BackendBatchLimit: cfg.BackendBatchLimit,
BackendBatchInterval: cfg.BackendBatchInterval,
MaxTxnOps: cfg.MaxTxnOps, MaxTxnOps: cfg.MaxTxnOps,
MaxRequestBytes: cfg.MaxRequestBytes, MaxRequestBytes: cfg.MaxRequestBytes,
StrictReconfigCheck: cfg.StrictReconfigCheck, StrictReconfigCheck: cfg.StrictReconfigCheck,

View File

@ -155,6 +155,8 @@ func newConfig() *config {
fs.UintVar(&cfg.ec.ElectionMs, "election-timeout", cfg.ec.ElectionMs, "Time (in milliseconds) for an election to timeout.") fs.UintVar(&cfg.ec.ElectionMs, "election-timeout", cfg.ec.ElectionMs, "Time (in milliseconds) for an election to timeout.")
fs.BoolVar(&cfg.ec.InitialElectionTickAdvance, "initial-election-tick-advance", cfg.ec.InitialElectionTickAdvance, "Whether to fast-forward initial election ticks on boot for faster election.") fs.BoolVar(&cfg.ec.InitialElectionTickAdvance, "initial-election-tick-advance", cfg.ec.InitialElectionTickAdvance, "Whether to fast-forward initial election ticks on boot for faster election.")
fs.Int64Var(&cfg.ec.QuotaBackendBytes, "quota-backend-bytes", cfg.ec.QuotaBackendBytes, "Raise alarms when backend size exceeds the given quota. 0 means use the default quota.") fs.Int64Var(&cfg.ec.QuotaBackendBytes, "quota-backend-bytes", cfg.ec.QuotaBackendBytes, "Raise alarms when backend size exceeds the given quota. 0 means use the default quota.")
fs.DurationVar(&cfg.ec.BackendBatchInterval, "backend-batch-interval", cfg.ec.BackendBatchInterval, "BackendBatchInterval is the maximum time before commit the backend transaction.")
fs.IntVar(&cfg.ec.BackendBatchLimit, "backend-batch-limit", cfg.ec.BackendBatchLimit, "BackendBatchLimit is the maximum operations before commit the backend transaction.")
fs.UintVar(&cfg.ec.MaxTxnOps, "max-txn-ops", cfg.ec.MaxTxnOps, "Maximum number of operations permitted in a transaction.") fs.UintVar(&cfg.ec.MaxTxnOps, "max-txn-ops", cfg.ec.MaxTxnOps, "Maximum number of operations permitted in a transaction.")
fs.UintVar(&cfg.ec.MaxRequestBytes, "max-request-bytes", cfg.ec.MaxRequestBytes, "Maximum client request size in bytes the server will accept.") fs.UintVar(&cfg.ec.MaxRequestBytes, "max-request-bytes", cfg.ec.MaxRequestBytes, "Maximum client request size in bytes the server will accept.")
fs.DurationVar(&cfg.ec.GRPCKeepAliveMinTime, "grpc-keepalive-min-time", cfg.ec.GRPCKeepAliveMinTime, "Minimum interval duration that a client should wait before pinging server.") fs.DurationVar(&cfg.ec.GRPCKeepAliveMinTime, "grpc-keepalive-min-time", cfg.ec.GRPCKeepAliveMinTime, "Minimum interval duration that a client should wait before pinging server.")

View File

@ -69,6 +69,10 @@ Member:
Maximum number of wal files to retain (0 is unlimited). Maximum number of wal files to retain (0 is unlimited).
--quota-backend-bytes '0' --quota-backend-bytes '0'
Raise alarms when backend size exceeds the given quota (0 defaults to low space quota). Raise alarms when backend size exceeds the given quota (0 defaults to low space quota).
--backend-batch-interval ''
BackendBatchInterval is the maximum time before commit the backend transaction.
--backend-batch-limit '0'
BackendBatchLimit is the maximum operations before commit the backend transaction.
--max-txn-ops '128' --max-txn-ops '128'
Maximum number of operations permitted in a transaction. Maximum number of operations permitted in a transaction.
--max-request-bytes '1572864' --max-request-bytes '1572864'

View File

@ -31,6 +31,18 @@ import (
func newBackend(cfg ServerConfig) backend.Backend { func newBackend(cfg ServerConfig) backend.Backend {
bcfg := backend.DefaultBackendConfig() bcfg := backend.DefaultBackendConfig()
bcfg.Path = cfg.backendPath() bcfg.Path = cfg.backendPath()
if cfg.BackendBatchLimit != 0 {
bcfg.BatchLimit = cfg.BackendBatchLimit
if cfg.Logger != nil {
cfg.Logger.Info("setting backend batch limit", zap.Int("batch limit", cfg.BackendBatchLimit))
}
}
if cfg.BackendBatchInterval != 0 {
bcfg.BatchInterval = cfg.BackendBatchInterval
if cfg.Logger != nil {
cfg.Logger.Info("setting backend batch interval", zap.Duration("batch interval", cfg.BackendBatchInterval))
}
}
bcfg.Logger = cfg.Logger bcfg.Logger = cfg.Logger
if cfg.QuotaBackendBytes > 0 && cfg.QuotaBackendBytes != DefaultQuotaBytes { if cfg.QuotaBackendBytes > 0 && cfg.QuotaBackendBytes != DefaultQuotaBytes {
// permit 10% excess over quota for disarm // permit 10% excess over quota for disarm

View File

@ -55,6 +55,11 @@ type ServerConfig struct {
MaxSnapFiles uint MaxSnapFiles uint
MaxWALFiles uint MaxWALFiles uint
// BackendBatchInterval is the maximum time before commit the backend transaction.
BackendBatchInterval time.Duration
// BackendBatchLimit is the maximum operations before commit the backend transaction.
BackendBatchLimit int
InitialPeerURLsMap types.URLsMap InitialPeerURLsMap types.URLsMap
InitialClusterToken string InitialClusterToken string
NewCluster bool NewCluster bool