|
| 1 | +# twemproxy |
| 2 | + |
| 3 | +#### Table of Contents |
| 4 | + |
| 5 | +1. [Overview](#overview) |
| 6 | +2. [Module Description - What the module does and why it is useful](#module-description) |
| 7 | +3. [Setup - The basics of getting started with twemproxy](#setup) |
| 8 | + * [Beginning with twemproxy](#beginning-with-twemproxy) |
| 9 | +4. [Usage - Configuration options and additional functionality](#usage) |
| 10 | +5. [Reference - An under-the-hood peek at what the module is doing and how](#reference) |
| 11 | +5. [Limitations - OS compatibility, etc.](#limitations) |
| 12 | +6. [Development - Guide for contributing to the module](#development) |
| 13 | + |
| 14 | +## Overview |
| 15 | + |
| 16 | +It's a puppet module for installing and configuring Twemproxy - memcached proxy |
| 17 | +created in Twitter. Tested for: |
| 18 | + |
| 19 | +* Ubuntu trusty |
| 20 | + |
| 21 | +Should work for most linux distros. |
| 22 | + |
| 23 | +## Module Description |
| 24 | + |
| 25 | +This module install, configure and run twemproxy. You can do any of these tasks |
| 26 | +separately or combine them for installing twemproxy from scratch. |
| 27 | + |
| 28 | + |
| 29 | +## Setup |
| 30 | + |
| 31 | +### Beginning with twemproxy |
| 32 | + |
| 33 | +I believe that it should be enough to call |
| 34 | + |
| 35 | +```puppet |
| 36 | +class { 'twemproxy': |
| 37 | + clients_array => $memcache_array, |
| 38 | +} |
| 39 | +``` |
| 40 | +with array of `<memcache node address>:<port>:<weight>` values to start using |
| 41 | +twemproxy and force it to do something useful |
| 42 | + |
| 43 | +## Usage |
| 44 | + |
| 45 | +Most of the work can be done through main twemproxy class, so you can just call |
| 46 | +`::twemproxy` with options you need to use all functionality this module covers |
| 47 | + |
| 48 | +###I need just setup twemproxy and create a pool with servers, what should I do? |
| 49 | + |
| 50 | +```puppet |
| 51 | +class { 'twemproxy: |
| 52 | + clients_array => ['10.10.10.10:11211:1', '10.10.10.20:11211:1'], |
| 53 | +} |
| 54 | +``` |
| 55 | + |
| 56 | +###I need just manage already existing config |
| 57 | + |
| 58 | +```puppet |
| 59 | +twemproxy::pool { 'mypool': |
| 60 | + listen_address => '127.0.0.1', |
| 61 | + listen_port => '22122', |
| 62 | + timeout => '400', |
| 63 | + redis => false, |
| 64 | + redis_auth => false, |
| 65 | + server_connections => 1, |
| 66 | + server_retry_timeout => 3000, |
| 67 | + clients_array => ['10.10.10.10:11211:1', '10.10.10.20:11211:1'], |
| 68 | +} |
| 69 | +``` |
| 70 | + |
| 71 | +## Reference |
| 72 | + |
| 73 | +### Classes |
| 74 | + |
| 75 | +* twemproxy: main class, include all others. |
| 76 | +* twemproxy::install: handles the package. |
| 77 | +* twemproxy::config: handles the daemon configuration file. |
| 78 | +* twemproxy::service: handles the service. |
| 79 | +* twemproxy::params: handles most of the parameters. |
| 80 | + |
| 81 | +### Defined types |
| 82 | + |
| 83 | +* twemproxy::listen: defines config part for twemproxy pool itself. |
| 84 | +* twemproxy::member: defines config part for memcache members in pool. |
| 85 | +* twemproxy::pool: combine previous two defines to one pool config. |
| 86 | + |
| 87 | +### Parameters |
| 88 | + |
| 89 | +Next parameter available in main twempxory class: |
| 90 | + |
| 91 | +####`package_manage` |
| 92 | +Tells whether we should manage twemproxy package. Valid options: 'true' or |
| 93 | +'false'. Default option: 'true'. |
| 94 | + |
| 95 | +####`package_name` |
| 96 | +Tells package name we should manage. |
| 97 | + |
| 98 | +####`package_ensure` |
| 99 | +Set what we should do with package. Valid options: 'present' or 'absent'. |
| 100 | +Default value: 'present'. |
| 101 | + |
| 102 | +####`service_manage` |
| 103 | +Tells if we should manage twemproxy service. Valid options: 'true' or 'false'. |
| 104 | +Default option: 'true' |
| 105 | + |
| 106 | +####`service_name` |
| 107 | +Set service name for twemproxy. |
| 108 | + |
| 109 | +####`service_ensure` |
| 110 | +Tells if we should install or remove service. Valid options: 'running' or |
| 111 | +'stopped'. Default option: 'running' |
| 112 | + |
| 113 | +####`service_enable` |
| 114 | +Tells if we should enable service on system start. Valid options: 'true' or |
| 115 | +'false'. Default option: 'true' |
| 116 | + |
| 117 | +####`listen_address` |
| 118 | +Address twemproxy will listen on. Default value: '127.0.0.1' |
| 119 | + |
| 120 | +####`listen_port` |
| 121 | +Port twemproxy will listen on. Default value: 22122 |
| 122 | + |
| 123 | +####`timeout` |
| 124 | +The timeout value in msec that twemproxy will wait for to establish a connection |
| 125 | +o the server or receive a response from a server. Set it to false if you want |
| 126 | +to wait indefinitely. Default value: 400 |
| 127 | + |
| 128 | +####`backlog` |
| 129 | +The TCP backlog argument. Default value: 1024 |
| 130 | + |
| 131 | +####`preconnect` |
| 132 | +A boolean value that controls if twemproxy should preconnect to all the servers |
| 133 | +in this pool on process start. Default value: 'false' |
| 134 | + |
| 135 | +####`redis` |
| 136 | +A boolean value that controls if a server pool speaks redis or memcached |
| 137 | +protocol. Default value: 'false' |
| 138 | + |
| 139 | +####`redis_auth` |
| 140 | +Authenticate to the Redis server on connect. Default value: 'false' |
| 141 | + |
| 142 | +####`redis_db` |
| 143 | +The DB number to use on the pool servers. Defaults to false |
| 144 | + |
| 145 | +####`server_connections` |
| 146 | +The maximum number of connections that can be opened to each server. Default |
| 147 | +value: 1 |
| 148 | + |
| 149 | +####`auto_eject_hosts` |
| 150 | +A boolean value that controls if server should be ejected temporarily when it |
| 151 | +fails consecutively `server_failure_limit` times. Default value: 'false' |
| 152 | + |
| 153 | +####`server_retry_timeout` |
| 154 | +The timeout value in msec to wait for before retrying on a temporarily ejected |
| 155 | +server, when `auto_eject_host` is set to true. Default value: 30000 |
| 156 | + |
| 157 | +####`server_failure_limit` |
| 158 | +The number of consecutive failures on a server that would lead to it being |
| 159 | +temporarily ejected when `auto_eject_host` is set to true. Default value: 2 |
| 160 | + |
| 161 | +####`client_address` |
| 162 | +Address of client for twemproxy. |
| 163 | + |
| 164 | +####`client_port` |
| 165 | +Port which client will bind to. Default value: 11211 |
| 166 | + |
| 167 | +####`client_weight` |
| 168 | +Weight of client. Default value: 1 |
| 169 | + |
| 170 | +####`clients_array` |
| 171 | +Array with client conections. You can consider it like array with different |
| 172 | +clients pointed as '`client_address`:`client_port`:`client_weight`'. Example |
| 173 | +of use: |
| 174 | + |
| 175 | +```puppet |
| 176 | +[ |
| 177 | + '10.10.10.10:11211:1', |
| 178 | + '10.10.20.20:11211:1', |
| 179 | + '10.10.30.30:11211:2', |
| 180 | +] |
| 181 | +``` |
| 182 | + |
| 183 | +## Limitations |
| 184 | + |
| 185 | +This module was tested only on Ububtu trusty, but should probably work on |
| 186 | +other platforms too. |
| 187 | + |
| 188 | +## Development |
| 189 | + |
| 190 | +This module is completely free, so I would appreciate any pull-requests to it |
| 191 | +or its redistribution. |
| 192 | + |
| 193 | +## Contributors |
| 194 | + |
| 195 | +- Stanislaw Bogatkin |
0 commit comments