Skip to content

Instantly share code, notes, and snippets.

@minhpq331
Last active August 1, 2021 06:20
Show Gist options
  • Save minhpq331/7d5d486d21fff538bb1c8cc12abb6b08 to your computer and use it in GitHub Desktop.
Save minhpq331/7d5d486d21fff538bb1c8cc12abb6b08 to your computer and use it in GitHub Desktop.
Sysctl tuning
{
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3",
"labels": "com.docker.compose.project,com.docker.compose.service,com.docker.stack.namespace,com.docker.swarm.service.name,com.docker.swarm.task.name,com.docker.swarm.node.id"
}
}
version: "3.8"
services:
cadvisor:
image: google/cadvisor
ports:
- target: 8080
published: 9102
protocol: tcp
mode: host
volumes:
- /var/run/docker.sock:/var/run/docker.sock,readonly
- /:/rootfs
- /var/run:/var/run
- /sys:/sys
- /var/lib/docker/:/var/lib/docker
deploy:
mode: global
resources:
limits:
cpus: '0.10'
memory: 128M
reservations:
cpus: '0.10'
memory: 64M
node-exporter:
image: quay.io/prometheus/node-exporter
ports:
- target: 9100
published: 9101
protocol: tcp
mode: host
volumes:
- /proc:/host/proc
- /sys:/host/sys
- /:/rootfs
- /etc/hostname:/etc/host_hostname
hostname: "{{.Node.ID}}"
environment:
HOST_HOSTNAME: /etc/host_hostname
command: -collector.procfs "/host/proc" -collector.sysfs /host/sys -collector.textfile.directory /etc/node-exporter/ -collectors.enabled 'conntrack,diskstats,entropy,filefd,filesystem,loadavg,mdadm,meminfo,netdev,netstat,stat,textfile,time,vmstat,ipvs' -collector.filesystem.ignored-mount-points "^/(sys|proc|dev|host|etc)($$|/)"
deploy:
mode: global
resources:
limits:
cpus: '0.10'
memory: 32M
reservations:
cpus: '0.10'
memory: 16M
# Have a larger connection range available
net.ipv4.ip_local_port_range=1024 65000
# Reuse closed sockets faster
net.ipv4.tcp_tw_reuse=1
net.ipv4.tcp_fin_timeout=15
# The maximum number of "backlogged sockets". Default is 128.
net.core.somaxconn=65535
net.core.netdev_max_backlog=4096
# 16MB per socket - which sounds like a lot,
# but will virtually never consume that much.
net.core.rmem_max=16777216
net.core.wmem_max=16777216
# Various network tunables
net.ipv4.tcp_max_syn_backlog=20480
net.ipv4.tcp_max_tw_buckets=400000
net.ipv4.tcp_no_metrics_save=1
net.ipv4.tcp_rmem=4096 87380 16777216
net.ipv4.tcp_syn_retries=2
net.ipv4.tcp_synack_retries=2
net.ipv4.tcp_wmem=4096 65536 16777216
#vm.min_free_kbytes=65536
# Connection tracking to prevent dropped connections (usually issue on LBs)
net.netfilter.nf_conntrack_max=262144
net.ipv4.netfilter.ip_conntrack_generic_timeout=120
net.netfilter.nf_conntrack_tcp_timeout_established=86400
# ARP cache settings for a highly loaded docker swarm
net.ipv4.neigh.default.gc_thresh1=8096
net.ipv4.neigh.default.gc_thresh2=12288
net.ipv4.neigh.default.gc_thresh3=16384
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment