I’m not having a problem per se, but I’ll provide the template information for completeness and pose my question at the end.
1. Output of caddy version
:
(devel)
(I’m on NixOS; the source revision is 2.5.2)
2. How I run Caddy:
a. System environment:
root@nixos:~/ > nixos-version
22.05.20220825.058de38 (Quokka)
root@nixos:~/ > systemctl --version
systemd 250 (250.4)
b. Command:
It’s a systemd service with WantedBy=multi-user.target
c. Service/unit/compose file:
caddy.service
Description=Caddy
Documentation=https://caddyserver.com/docs/
After=network.target network-online.target
Requires=network-online.target
StartLimitBurst=10
StartLimitIntervalSec=14400
[Service]
Type=notify
User=caddy
Group=caddy
Environment=“LOCALE_ARCHIVE=/nix/store/fqmdxlbk32miazamkyavwwiwkn146i37-glibc-locales-2.34-210/lib/locale/locale-archive”
Environment=“PATH=/nix/store/p643r4aczmzb0dhyrx3dj592f0s5v7xj-coreutils-9.0/bin:/nix/store/7g48ahc3xnmb5b851vw60nbdgvk0wsf8-findutils-4.9.0/bin:/nix/store/ja8bi2cbpm36nwqy1hvklm3y9n7s3247-gnugrep-3.7/bin:/nix/store/lrxxki2m4gr4w3lxw08qpd465skpa04y-gnused-4.8/bin:/nix/store/sj364k7lsr47i87f7iv835lvvn7g4fqm-systemd-250.4/bin:/nix/store/p643r4aczmzb0dhyrx3dj592f0s5v7xj-coreutils-9.0/sbin:/nix/store/7g48ahc3xnmb5b851vw60nbdgvk0wsf8-findutils-4.9.0/sbin:/nix/store/ja8bi2cbpm36nwqy1hvklm3y9n7s3247-gnugrep-3.7/sbin:/nix/store/lrxxki2m4gr4w3lxw08qpd465skpa04y-gnused-4.8/sbin:/nix/store/sj364k7lsr47i87f7iv835lvvn7g4fqm-systemd-250.4/sbin”
Environment=“TZDIR=/nix/store/4lh2brlyffixgz1z31p51q5i0y395lqa-tzdata-2022b/share/zoneinfo”
ExecStart=/nix/store/6kq7pfy5yiil6bms3qs4dg0z2bl3z6bi-caddy-2.5.2/bin/caddy run --environ --config /etc/caddy/Caddyfile
ExecReload=/nix/store/6kq7pfy5yiil6bms3qs4dg0z2bl3z6bi-caddy-2.5.2/bin/caddy reload --config /etc/caddy/Caddyfile
TimeoutStopSec=5s
LimitNOFILE=1048576
LimitNPROC=512
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE
ExecReload=
ExecReload=/nix/store/6kq7pfy5yiil6bms3qs4dg0z2bl3z6bi-caddy-2.5.2/bin/caddy reload --config /nix/store/ysmpqr5gps9fl8kx9m0m29s9qfc6zryv-Caddyfile --adapter caddyfile
ExecStart=
ExecStart=/nix/store/6kq7pfy5yiil6bms3qs4dg0z2bl3z6bi-caddy-2.5.2/bin/caddy run --config /nix/store/ysmpqr5gps9fl8kx9m0m29s9qfc6zryv-Caddyfile --adapter caddyfile
ExecStartPre=/nix/store/6kq7pfy5yiil6bms3qs4dg0z2bl3z6bi-caddy-2.5.2/bin/caddy validate --config /nix/store/ysmpqr5gps9fl8kx9m0m29s9qfc6zryv-Caddyfile --adapter caddyfile
Group=caddy
LimitNOFILE=250000:250000
LogsDirectory=caddy
NoNewPrivileges=true
PrivateDevices=true
ProtectHome=true
ReadWriteDirectories=/var/lib/caddy
Restart=on-abnormal
StateDirectory=caddy
User=caddy
[Install]
WantedBy=multi-user.target
d. My complete Caddy config:
:8080 {
handle_path /html {
root * /nix/store/carv5x76ywyfhiq1rvqccrbpqnfvxrmb-static-html
file_server
}
handle /synthetic {
respond "Hello, world!"
}
handle /proxy {
reverse_proxy localhost:8081
}
}
3. The problem I’m having:
I’m benchmarking Caddy. My Caddyfile
works, so I’m primarily interested in whatever performance-related improvements I can make to make each of the three handlers respond speedily.
4. Error messages and/or full log output:
(no errors)
5. What I already tried:
I’ve done some reading both on these forums and on the Internet generally, but am looking for some more a) up-to-date and b) specific suggestions (if there are any)
6. Links to relevant resources:
(nil)
Hi! I’m the obnoxious user on Twitter who started this thread with whomever runs the Caddy account asking about performance. I’m running… lots of tests in a variety of scenarios against a like Nginx configuration.
I’m breaking apart benchmarking scenarios into a few different categories, including using a) default configuration file settings and b) optimized configuration file settings. My Caddyfile
is intentionally bare in order to solely test i) hard-coded “synthetic” responses, ii) file serving, and iii) proxied requests.
Given my example Caddyfile
, what (if any) performance optimizations are there to be had? My only real finding was to possibly install this caching module in order to cache responses. I’m already tweaking some sysctl
settings like bumping up NOFILE
(to 250000) and these as well just for general web-serving performance:
net.ipv4.ip_local_port_range "1024 65535"
net.ipv4.tcp_tw_reuse 1
net.ipv4.tcp_timestamps 1
Any general guidance? Thank you!