qdm12 / gluetun

VPN client in a thin Docker container for multiple VPN providers, written in Go, and using OpenVPN or Wireguard, DNS over TLS, with a few proxy servers built-in.
https://hub.docker.com/r/qmcgaw/gluetun
MIT License
7.86k stars 364 forks source link

Bug: Small CPU spikes every 5 seconds #879

Closed jaller94 closed 2 years ago

jaller94 commented 2 years ago

Is this urgent?

No

Host OS

Manjaro Linux

CPU arch

x86_64

VPN service provider

ProtonVPN

What are you using to run the container

docker-compose

What is the version of Gluetun

2022-02-26T23:00:01.006Z (commit 006b218)

What's the problem 🤔

Every 5 seconds I get a small CPU spike of 3% to 6% for less than a second. Even when the proxy should be completely idle.

I suspect that this could be the health check or another network call. With each spike docker stats says that ~0.3 kb are being uploaded and downloaded.

I would prefer an option for the container to not make frequent network calls and avoid regular CPU spikes.

Share your logs

Running version latest built on 2022-02-26T23:00:01.006Z (commit 006b218)

🔧 Need help? https://github.com/qdm12/gluetun/discussions/new
🐛 Bug? https://github.com/qdm12/gluetun/issues/new
✨ New feature? https://github.com/qdm12/gluetun/issues/new
☕ Discussion? https://github.com/qdm12/gluetun/discussions/new
💻 Email? quentin.mcgaw@gmail.com
💰 Help me? https://www.paypal.me/qmcgaw https://github.com/sponsors/qdm12
2022/03/04 22:23:59 INFO routing: default route found: interface eth0, gateway 172.24.0.1
2022/03/04 22:23:59 INFO routing: local ethernet link found: eth0
2022/03/04 22:23:59 INFO routing: local ipnet found: 172.24.0.0/16
2022/03/04 22:23:59 INFO firewall: enabling...
2022/03/04 22:23:59 INFO firewall: enabled successfully
2022/03/04 22:23:59 INFO storage: merging by most recent 11096 hardcoded servers and 11096 servers read from /gluetun/servers.json
2022/03/04 22:23:59 INFO Alpine version: 3.15.0
2022/03/04 22:23:59 INFO OpenVPN 2.4 version: 2.4.11
2022/03/04 22:23:59 INFO OpenVPN 2.5 version: 2.5.4
2022/03/04 22:23:59 INFO Unbound version: 1.13.2
2022/03/04 22:23:59 INFO IPtables version: v1.8.7
2022/03/04 22:23:59 INFO Settings summary:
├── VPN settings:
|   ├── VPN provider settings:
|   |   ├── Name: protonvpn
|   |   └── Server selection settings:
|   |       ├── VPN type: openvpn
|   |       ├── Countries: germany
|   |       └── OpenVPN server selection settings:
|   |           └── Protocol: UDP
|   └── OpenVPN settings:
|       ├── OpenVPN version: 2.5
|       ├── User: [set]
|       ├── Password: [set]
|       ├── Tunnel IPv6: no
|       ├── Network interface: tun0
|       ├── Run OpenVPN as: root
|       └── Verbosity level: 1
├── DNS settings:
|   ├── DNS server address to use: 127.0.0.1
|   ├── Keep existing nameserver(s): no
|   └── DNS over TLS settings:
|       └── Enabled: no
├── Firewall settings:
|   └── Enabled: yes
├── Log settings:
|   └── Log level: INFO
├── Health settings:
|   ├── Server listening address: 127.0.0.1:9999
|   ├── Address to ping: github.com
|   └── VPN wait durations:
|       ├── Initial duration: 5s
|       └── Additional duration: 5s
├── Shadowsocks server settings:
|   └── Enabled: no
├── HTTP proxy settings:
|   ├── Enabled: yes
|   ├── Listening address: :8888
|   ├── User: 
|   ├── Password: [not set]
|   ├── Stealth mode: no
|   └── Log: no
├── Control server settings:
|   ├── Listening address: :8000
|   └── Logging: no
├── OS Alpine settings:
|   ├── Process UID: 1000
|   └── Process GID: 1000
├── Public IP settings:
|   ├── Fetching: every 12h0m0s
|   └── IP file path: /tmp/gluetun/ip
└── Version settings:
    └── Enabled: yes
2022/03/04 22:23:59 INFO routing: default route found: interface eth0, gateway 172.24.0.1
2022/03/04 22:23:59 INFO routing: adding route for 0.0.0.0/0
2022/03/04 22:23:59 INFO firewall: setting allowed subnets...
2022/03/04 22:23:59 INFO routing: default route found: interface eth0, gateway 172.24.0.1
2022/03/04 22:23:59 INFO TUN device is not available: open /dev/net/tun: no such file or directory; creating it...
2022/03/04 22:23:59 INFO pprof http server listening on [::]:6060
2022/03/04 22:23:59 INFO dns over tls: using plaintext DNS at address 1.1.1.1
2022/03/04 22:23:59 INFO healthcheck: listening on 127.0.0.1:9999
2022/03/04 22:23:59 INFO http proxy: listening on :8888
2022/03/04 22:23:59 INFO firewall: allowing VPN connection...
2022/03/04 22:23:59 INFO http server: listening on :8000
2022/03/04 22:23:59 INFO openvpn: OpenVPN 2.5.4 x86_64-alpine-linux-musl [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [MH/PKTINFO] [AEAD] built on Nov 15 2021
2022/03/04 22:23:59 INFO openvpn: library versions: OpenSSL 1.1.1l  24 Aug 2021, LZO 2.10
2022/03/04 22:23:59 INFO openvpn: TCP/UDP: Preserving recently used remote address: [AF_INET]185.159.158.157:1194
2022/03/04 22:23:59 INFO openvpn: UDP link local: (not bound)
2022/03/04 22:23:59 INFO openvpn: UDP link remote: [AF_INET]185.159.158.157:1194
2022/03/04 22:24:00 WARN openvpn: 'link-mtu' is used inconsistently, local='link-mtu 1633', remote='link-mtu 1634'
2022/03/04 22:24:00 WARN openvpn: 'comp-lzo' is present in remote config but missing in local config, remote='comp-lzo'
2022/03/04 22:24:00 INFO openvpn: [lxc-de-11.protonvpn.com] Peer Connection Initiated with [AF_INET]185.159.158.157:1194
2022/03/04 22:24:01 INFO openvpn: setsockopt TCP_NODELAY=1 failed
2022/03/04 22:24:01 INFO openvpn: TUN/TAP device tun0 opened
2022/03/04 22:24:01 INFO openvpn: /sbin/ip link set dev tun0 up mtu 1500
2022/03/04 22:24:01 INFO openvpn: /sbin/ip link set dev tun0 up
2022/03/04 22:24:01 INFO openvpn: /sbin/ip addr add dev tun0 10.31.0.3/16
2022/03/04 22:24:01 INFO openvpn: UID set to nonrootuser
2022/03/04 22:24:01 INFO openvpn: Initialization Sequence Completed
2022/03/04 22:24:07 INFO healthcheck: healthy!
2022/03/04 22:24:07 INFO vpn: You are running on the bleeding edge of latest!
2022/03/04 22:24:07 INFO ip getter: Public IP address is xx.xx.xx.xx (Germany, xx, xx)

Share your configuration

version: "3"
services:
  gluetun:
    image: qmcgaw/gluetun
    cap_add:
      - NET_ADMIN
    environment:
      - VPN_SERVICE_PROVIDER=protonvpn
      - OPENVPN_USER=xxxx
      - OPENVPN_PASSWORD=xxxx
      - SERVER_COUNTRIES=Germany
      - HTTPPROXY=on
      - DOT=off
      - HTTP_CONTROL_SERVER_LOG=off
    ports:
      - 8889:8888
qdm12 commented 2 years ago

This is due to the healthcheck (internal to gluetun, not the Docker one). It pings github.com (so dns resolution + icmp) every 5s by default to check if the connection is up. You can change those values, see the health options wiki page for that. On the other hand, it means it won't detect the vpn doesn't work and auto-heal itself in a short time.