tpc roughly stands for Twemproxy Configurator
Listens to a cluster of redis sentinel servers via pubsub. Rewrites twemproxy config file and executes twemproxy reload command when sentinel notifies of redis master failover.
Download the latest release, extract it, and put it somewhere on your PATH.
or
$ go get github.com/atongen/tpc
or
$ mkdir -p $GOPATH/src/github.com/atongen
$ cd $GOPATH/src/github.com/atongen
$ git clone git@github.com:atongen/tpc.git
$ cd tpc
$ go install
$ rehash
$ cd $GOPATH/src/github.com/atongen/tpc
$ go test -cover
$ mkdir -p $GOPATH/src/github.com/atongen
$ cd $GOPATH/src/github.com/atongen
$ git clone git@github.com:atongen/tpc.git
$ cd tpc
$ make release
λ tpc -h
Usage of tpc:
-auto_eject_hosts
Twemproxy: A boolean value that controls if server should be ejected temporarily when it fails consecutively server_failure_limit times.
-backlog int
Twemproxy: TCP backlog argument (default 1024)
-channel string
Slack: channel for notifications (default "#incidents")
-client_connections int
Twemproxy: The maximum number of connections allowed from redis clients (default 4096)
-cmd string
Process: Command to execute after master failover
-distribution string
Twemproxy: Key distribution (default "ketama")
-has_tag string
Twemproxy: A two character string that specifies the part of the key used for hashing. Eg '{}' or '$$'
-hash string
Twemproxy: Hash algorithm (default "fnv1a_64")
-icon_emoji string
Slack: icon emoji for notifications
-ip string
Twemproxy: Ip address (default "0.0.0.0")
-listen_address string
Prometheus: Listen address (default ":9298")
-log string
Process: Path to log file, will write to STDOUT if empty
-master_pattern string
Process: If provided, will filter master names from sentinel based on pattern
-name string
Twemproxy: Name of redis pool (default "redis")
-out string
Process: File to write configuration, will write to STDOUT if empty
-backup string
Process: Directory to write backup files, will write to STDOUT if empty
-port int
Twemproxy: Port (default 9000)
-preconnect
Twemproxy: A boolean value that controls if we should preconnect to all the servers in this pool on process start (default true)
-redis_auth string
Twemproxy: authenticate to the redis server on connect
-redis_db int
Twemproxy: The DB number to use on the redis pool servers. Twemproxy will always present itself to clients as DB 0
-sentinels string
Process: CSV of host:port to redis sentinels
-server_connections int
Twemproxy: The maximum number of connections that can be open to each server (default 1)
-server_failure_limit int
Twemproxy: The number of consecutive failures on a server that would lead to it being temporarily ejected when auto_eject_host is set to true. (default -1)
-server_retry_timeout int
Twemproxy: The timeout value in msec to wait for before retrying on a temporarily ejected server, when auto_eject_host is set to true. (default -1)
-telemetry_path string
Prometheus: Telemetry path (default "/metrics")
-timeout int
Twemproxy: The timeout value in msec that we wait for to establish a connection to the server or receive a response from a server. (default -1)
-token string
Slack: API token used for notifications
-username string
Slack: username for notifications
-v Print version information and exit
There is a long-running twemproxy feature branch that is supposed to bring config hot-reload via unix signal:
- twitter/twemproxy#6
- twitter/twemproxy#321
- https://github.com/machinezone/twemproxy/tree/lwalkin/config-reload
Currently the solution is to pause the redis clients, then stop and restart the twemproxy process.