269 words
1 minute
macOS Network Tuning
2025-05-12

Background#

I recently bought a few servers in physically distant locations — the US West Coast, Germany, and so on. Testing with iperf3 and speedtest showed severe single-thread download throttling (around 200Mbps). The pattern tracks latency: at 160ms the cap sits around 200Mbps, at 150ms around 220Mbps — the higher the latency, the tighter the cap and the lower the throughput.

The Current Defaults#

Since macOS 10.5, Apple has shipped “self-tuning TCP”, which dynamically adjusts certain parameters for performance. The defaults have improved over the years, but they still need tweaking to make full use of fast connections.

Recent macOS versions ship with the following defaults (exact values vary slightly by version):

  • net.inet.tcp.win_scale_factor: 3
  • net.inet.tcp.autorcvbufmax: 4194304
  • net.inet.tcp.autosndbufmax: 4194304

To optimize performance on 1Gbps-or-faster networks, raise the TCP window scaling factor and the autotuning buffer maxima. Add the settings below to /etc/sysctl.conf (or apply them on the fly with the sysctl command):

Modify net.inet.tcp.win_scale_factor, net.inet.tcp.autorcvbufmax, and net.inet.tcp.autosndbufmax.

How to Apply#

  1. sudo nano /etc/sysctl.conf
  2. Add the following:
Terminal window
# Increase TCP window scaling factor (default is 3-6; increase to 8)
net.inet.tcp.win_scale_factor=8
# Increase maximum receive buffer for TCP autotuning to 32MB
net.inet.tcp.autorcvbufmax=33554432
# Increase maximum send buffer for TCP autotuning to 32MB
net.inet.tcp.autosndbufmax=33554432
  1. Save, then run sudo sysctl -f /etc/sysctl.conf

Results#

Defaults#

iperf3 test#

iperf3 result with default settings

speedtest test#

speedtest result with default settings

After the Change#

iperf3 test#

iperf3 result after tuning

speedtest test#

speedtest result after tuning

WARNING
  • These settings are well suited to high-performance workloads — file servers, high-throughput applications, or research environments.
  • If they cause instability or hurt performance in your specific use case, revert them.
  • If iperf3 shows heavy Retr packet loss after the change, tune the macOS buffer sizes, or adjust the TCP buffer sizes on the VPS side.
macOS Network Tuning
https://www.mihouo.com/en/posts/server/macos-network-optimization/
Author
Jia
Published at
2025-05-12
License
CC BY-NC-SA 4.0