-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcompose.yaml.erb
73 lines (73 loc) · 2.63 KB
/
compose.yaml.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
---
# bin/render_compose > compose.massive.yaml
#
# https://developer.redis.com/operate/redis-at-scale/talking-to-redis/initial-tuning/
# https://github.com/redis/redis/blob/unstable/redis.conf
services:
node001: &node
image: "redis:${REDIS_VERSION:-7}"
command: >
redis-server
--maxmemory 32mb
--maxmemory-policy allkeys-lru
--maxmemory-clients 32%
--maxclients 256
--tcp-backlog 1024
--timeout 0
--tcp-keepalive 300
--save ""
--rdb-del-sync-files no
--replica-serve-stale-data yes
--replica-read-only yes
--repl-backlog-size 2mb
--repl-backlog-ttl 0
--repl-disable-tcp-nodelay yes
--repl-diskless-sync yes
--repl-diskless-sync-delay 0
--repl-diskless-sync-max-replicas 0
--repl-diskless-load on-empty-db
--repl-ping-replica-period 60
--repl-timeout 300
--min-replicas-to-write 0
--min-replicas-max-lag 0
--shutdown-timeout 0
--shutdown-on-sigint nosave force now
--shutdown-on-sigterm nosave force now
--client-output-buffer-limit replica 0 0 0
--client-query-buffer-limit 4mb
--appendonly no
--appendfsync no
--cluster-enabled yes
--cluster-config-file nodes.conf
--cluster-node-timeout 300000
--cluster-replica-validity-factor 5
restart: "${RESTART_POLICY:-always}"
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: "7s"
timeout: "5s"
retries: 10
ports:
- "<%= port %>:<%= port %>"
<% (2..n).each do |i| %>
node<%= sprintf('%03d', i) %>:
<<: *node
ports:
- "<%= port + i - 1 %>:<%= port %>"
<% end %>
clustering:
image: "redis:${REDIS_VERSION:-7}"
command: >
bash -c "apt-get update > /dev/null
&& apt-get install --no-install-recommends --no-install-suggests -y dnsutils > /dev/null
&& rm -rf /var/lib/apt/lists/*
&& yes yes | redis-cli --cluster create
<% n.times do |i| %>
$$(dig node<%= sprintf('%03d', i + 1) %> +short):<%= port %>
<% end %>
--cluster-replicas <%= (n - shards) / shards %>"
depends_on:
<% n.times do |i| %>
node<%= sprintf('%03d', i + 1) %>:
condition: service_healthy
<% end %>