add twemproxy

This commit is contained in:
kev 2019-11-07 14:03:03 +08:00
parent 9d85e2bb2c
commit 0b0f664d21
7 changed files with 92 additions and 0 deletions

View File

@ -133,6 +133,7 @@ A collection of delicious docker recipes.
- [x] taskd
- [x] tftpd
- [x] tmail :beetle:
- [x] twemproxy
- [x] vsftpd
- [x] webhook
- [x] webkit :beetle:

29
twemproxy/Dockerfile Normal file
View File

@ -0,0 +1,29 @@
#
# Dockerfile for twemproxy
#
FROM alpine:3
ENV TWEMPROXY_VERSION=0.4.1
ENV TWEMPROXY_URL=https://github.com/twitter/twemproxy/archive/v${TWEMPROXY_VERSION}.tar.gz
ENV TWEMPROXY_HOME=/opt/twemproxy
WORKDIR ${TWEMPROXY_HOME}
RUN set -xe \
&& apk --no-cache add -t TMP alpine-sdk autoconf automake curl libtool tar \
&& mkdir -p conf logs src \
&& curl -sSL ${TWEMPROXY_URL} | tar xz --strip 1 -C src \
&& cd src \
&& autoreconf -fvi \
&& CFLAGS="-O3" ./configure \
&& make install \
&& nutcracker --version \
&& cd .. \
&& rm -rf src \
&& apk del TMP
EXPOSE 22222
ENTRYPOINT ["nutcracker"]
CMD ["--help"]

28
twemproxy/README.md Normal file
View File

@ -0,0 +1,28 @@
twemproxy
=========
[twemproxy][1] (pronounced "two-em-proxy"), aka nutcracker is a fast and
lightweight proxy for memcached and redis protocol. It was built primarily to
reduce the number of connections to the caching servers on the backend. This,
together with protocol pipelining and sharding enables you to horizontally
scale your distributed caching architecture.
## up and running
```bash
$ docker-compose up -d
$ docker-compose exec redis redis-cli -h twemproxy
twemproxy:6379> ping
PONG
twemproxy:6379> set hello world
OK
twemproxy:6379> get hello
"world"
twemproxy:6379> del hello
(integer) 1
$ tail -f data/twemproxy/logs/nutcracker.log
```
[1]: https://github.com/twitter/twemproxy

View File

View File

@ -0,0 +1,10 @@
alpha:
listen: 0.0.0.0:6379
hash: fnv1a_64
distribution: ketama
auto_eject_hosts: true
redis: true
server_retry_timeout: 2000
server_failure_limit: 1
servers:
- redis:6379:1

View File

@ -0,0 +1,24 @@
version: "3.7"
services:
twemproxy:
image: vimagick/twemproxy
command: >
--conf-file=conf/nutcracker.yml
--output=logs/nutcracker.log
--verbose=5
ports:
- "6379:6379"
- "22222:22222"
volumes:
- ./data/twemproxy:/opt/twemproxy
depends_on:
- redis
restart: unless-stopped
redis:
image: redis:alpine
volumes:
- ./data/redis:/data
restart: unless-stopped