Networking

TCP Slow Start and initcwnd: A Practical Guide for Linux Servers

By NileVPS Team · Published · 5 min read

اقرأ المقال بالعربي

When a TCP connection opens, the sender has no idea how much bandwidth the path can carry. Sending everything at once could overflow a router queue and cause heavy packet loss, so TCP starts cautiously and speeds up as acknowledgments come back. This phase is called slow start, and its starting point is the initial congestion window, or initcwnd. For short transfers such as API responses, small web pages and handshake-heavy traffic, slow start often decides how fast the response feels, more than raw bandwidth does. This guide explains the mechanism and shows how to inspect and tune it on a Linux VPS.

How slow start works

The sender keeps a congestion window (cwnd): the number of segments it may have in flight without acknowledgment. One segment is roughly one MSS, about 1448 bytes of payload on a typical Ethernet path.

  • The connection starts with cwnd equal to initcwnd.
  • For every segment acknowledged, cwnd grows by one segment, which in practice roughly doubles cwnd every round trip.
  • Growth continues until cwnd reaches the slow start threshold (ssthresh) or a loss is detected. Then the congestion control algorithm, such as CUBIC or BBR, takes over with its own rules.

Because growth happens per round trip, latency matters a lot. With initcwnd of 10 segments, the first round trip can deliver about 14 KB. A 100 KB response needs several round trips even on a gigabit link. On a path with 150 ms RTT, each of those trips adds 150 ms.

The default initcwnd on Linux

Modern Linux kernels use an initcwnd of 10 segments, following RFC 6928. Older kernels used 3 or 4. You can see the effective values for live connections with ss:

ss -tin state established '( sport = :443 )'

In the output, look for fields such as cwnd:10, ssthresh:, rtt: and mss:. A new connection will show cwnd near 10, while a long transfer will show much larger numbers.

There is no global sysctl for initcwnd. It is set per route, using the initcwnd and initrwnd attributes in the routing table.

Inspecting and changing initcwnd per route

Show your routes:

ip route show

A typical output contains a line like default via 172.31.1.1 dev eth0. To change the initial congestion window on that route, repeat the route exactly and add the attributes:

sudo ip route change default via 172.31.1.1 dev eth0 initcwnd 20 initrwnd 20
ip route show

Use your own gateway and interface name; never copy the example blindly. initrwnd sets the initial receive window your server advertises, which matters when the VPS is the one downloading.

Be careful when editing the default route over SSH. A typo can drop connectivity. Keep a browser console or out-of-band access available before experimenting.

Making it persistent

ip route change is lost on reboot. How you persist it depends on your network stack:

  • systemd-networkd: in the [Route] section of your .network file, use InitialCongestionWindow=20 and InitialAdvertisedReceiveWindow=20.
  • Netplan: route entries support congestion-window and advertised-receive-window on recent versions. Check man netplan on your release.
  • ifupdown: add a post-up ip route change ... line to the interface stanza in /etc/network/interfaces.

Whichever method you use, reboot once in a maintenance window and confirm with ip route show.

Slow start after idle

By default Linux resets cwnd when a connection has been idle for longer than its retransmission timeout. This is controlled by net.ipv4.tcp_slow_start_after_idle, which defaults to 1. For long-lived connections that send bursts with pauses in between, such as HTTP/2 connections, WebSockets or database links, every burst after a pause starts slowly again.

sysctl net.ipv4.tcp_slow_start_after_idle
echo "net.ipv4.tcp_slow_start_after_idle = 0" | sudo tee /etc/sysctl.d/60-tcp-idle.conf
sudo sysctl --system

Setting it to 0 keeps the window across idle periods. The trade-off is that network conditions may have changed during the pause, so a large burst could hit a now-congested path. For most server workloads, disabling it is a common and reasonable choice.

Cached metrics

Linux also remembers metrics such as ssthresh per destination and can reuse them for new connections. View them with:

ip tcp_metrics show

If a past loss left a small ssthresh cached for a client, new connections may leave slow start early. sudo ip tcp_metrics flush clears the cache, and net.ipv4.tcp_no_metrics_save = 1 stops saving metrics altogether. Change this only if you see a measurable problem.

Should you raise initcwnd?

SituationSuggestion
General web or API serverKeep the default of 10
Long-lived bursty connectionsConsider tcp_slow_start_after_idle = 0
Controlled private links between your serversTest a higher initcwnd and measure
Clients on lossy or congested mobile networksAvoid large initcwnd values

A larger initcwnd sends a bigger first burst. On clean paths that can shave a round trip off small responses; on congested paths it can cause loss and retransmissions that make things slower. Measure before and after with real traffic, for example with curl -w "%{time_starttransfer} %{time_total}\n" from a distant location. Pairing sensible slow start settings with a modern congestion control, covered in our TCP BBR guide, and properly sized socket buffers gives the best overall results.

FAQ

What is a good initcwnd value for a Linux server?

The default of 10 segments is well tested and suits most servers. Higher values may help on clean, controlled paths, but they should be adopted only after measuring real latency, since they can increase loss on congested networks.

Does BBR replace slow start?

Not entirely. BBR has its own startup phase that probes bandwidth quickly, but it still begins from the initial congestion window. initcwnd and the slow start after idle setting still influence how a BBR connection begins sending.

Why does my initcwnd change disappear after a reboot?

Changes made with ip route change exist only in the running routing table. Add the setting to your network configuration, such as systemd-networkd, Netplan or ifupdown, so it is applied each time the interface comes up.

Related guides