Skip to content

Bandwidth throttling and connection limits on LiteSpeed

Learn how to set bandwidth throttling and connection limits on LiteSpeed so one busy site or one abusive visitor cannot slow down the whole server. This guide shows which settings to change and safe starting values for WordPress hosting.

This guide is for admins running LiteSpeed Web Server who want to stop one site or one visitor from hogging the server. On a shared server, a single virtual host (one website’s configuration) can use far more than its fair share of bandwidth. A single client IP address can also open dozens of connections, or send requests fast enough to slow everyone else down. LiteSpeed handles both with built-in settings, so you do not need an extra module. You can cap total connections for the whole server, and limit request rate and download speed for each site. You can also limit how many connections each IP address may hold. Visitors who go over a limit are slowed down first, and banned for a few minutes only if they keep pushing. Below you will find each setting, where it lives, and values that work well for typical WordPress hosting.

How to verify

Check the current throttle state and test that limits are being enforced:

# Review current connection count per client IP
ss -tn state established | awk '{print $5}' | cut -d: -f1 | \
  sort | uniq -c | sort -rn | head -20

# Confirm throttle directives are present in the vhost config
grep -E 'throttle|connLimit|maxConns|banPeriod' \
  /usr/local/lsws/conf/vhosts/example.com/vhconf.conf

# LiteSpeed real-time status (Enterprise — WebAdmin or CLI)
/usr/local/lsws/bin/lshttpd -s 2>/dev/null | grep -iE 'conn|bps'

# Test bandwidth throttle with a large file download
curl -w "avg speed: %{speed_download} B/s\n" -o /dev/null \
  https://example.com/large-file.zip

# Check server-level limits in main config
grep -E 'maxConnections|throttle' /usr/local/lsws/conf/httpd_config.conf

What’s happening

LiteSpeed’s throttle system operates at three levels, and understanding the hierarchy prevents accidental over-restriction.

At the server level, maxConnections sets the absolute ceiling on simultaneous connections across all vhosts. When this limit is reached, new connections are queued or rejected depending on the listener backlog setting. This is a hard resource cap, not a per-client limit.

At the virtual host level, throttle controls how many requests per second a single vhost will process from a single client IP, and at what bandwidth rate. A client that exceeds the request rate is throttled (delayed), not immediately rejected. Bandwidth throttling at this level caps the outbound byte rate for responses — useful for media-heavy sites where a single downloader can saturate a shared link.

At the connection level, per-IP connection limits (dynReqPerSec and connLimit) control how many simultaneous connections and how many new requests per second a single IP address may make. When a client exceeds the connection limit, LiteSpeed can respond with a 503, a CAPTCHA redirect (if configured), or a temporary IP ban. The ban period is configured via banPeriod and applies at the server level, blocking the IP across all vhosts.

The important distinction is between throttling (slowing a client down while still serving them) and banning (dropping their connections entirely). Throttling is appropriate for download speed limits; banning is appropriate for abusive request rates.

The procedure

1. Set server-level connection ceiling.

In /usr/local/lsws/conf/httpd_config.conf:

maxConnections          500
maxSSLConnections       500

These values are per-server, not per-CPU. A typical shared WordPress hosting server can handle 300–500 simultaneous connections before PHP worker pool exhaustion becomes the bottleneck. Set these conservatively and monitor lshttpd -s during peak traffic.

2. Configure per-client-IP connection and request rate limits.

In the server-level connection control block:

connectionControl  {
  maxConnections      10
  dynReqPerSec        25
  staticReqPerSec     100
  outBandwidth        0
  inBandwidth         0
  softLimit           80
  hardLimit           100
  gracePeriod         15
  banPeriod           300
}

maxConnections 10 means a single IP may hold at most 10 simultaneous connections. dynReqPerSec 25 limits dynamic (PHP) requests to 25 per second per IP. softLimit and hardLimit are percentages of maxConnections at which throttling and then banning kick in. gracePeriod is the seconds LiteSpeed waits before enforcing the hard limit on a new connection. banPeriod 300 bans the IP for 5 minutes after exceeding the hard limit.

3. Configure per-vhost bandwidth throttle.

In your vhost config (/usr/local/lsws/conf/vhosts/example.com/vhconf.conf):

throttle  {
  dynReqPerSec        20
  staticReqPerSec     50
  outBandwidth        2048
  inBandwidth         1024
}

outBandwidth 2048 caps outbound at 2 MB/s per client IP for responses from this vhost. inBandwidth 1024 caps inbound (uploads) at 1 MB/s. Values are in kilobytes per second. Set outBandwidth 0 to disable bandwidth throttling while keeping request rate limits.

4. Configure per-context download throttle (optional).

For fine-grained control over specific URI prefixes (e.g., a downloads directory):

context /downloads/ {
  location              /var/www/example.com/html/downloads
  allowBrowse           1
  throttle {
    outBandwidth        512
  }
}

This limits downloads from /downloads/ to 512 KB/s per client without affecting the rest of the site.

5. Apply and validate.

sudo /usr/local/lsws/bin/lswsctrl -t
sudo /usr/local/lsws/bin/lswsctrl restart

# Simulate a high-connection client (requires wrk or similar)
wrk -t4 -c50 -d10s https://example.com/
# If limits are working, connection count to this IP will be capped and
# responses will include 503 when hard limit is reached

Common pitfalls

Cloudflare proxied IPs collapse all client traffic to Cloudflare edge IPs. If your site is behind Cloudflare, all requests appear to come from Cloudflare IP ranges. Per-IP connection limits will throttle Cloudflare itself, not individual end users. Either disable per-IP limits at the LiteSpeed level (let Cloudflare’s rate limiting handle it) or configure LiteSpeed to read the true client IP from CF-Connecting-IP via useIpInHeader 2.

banPeriod applies across all vhosts on the server. A client that triggers a ban on one vhost is banned from all vhosts for the ban duration. On a shared server hosting multiple clients’ sites, an aggressive ban policy on one site can lock out legitimate users of another. Review the ban threshold values carefully in multi-tenant environments.

dynReqPerSec counts PHP-dispatched requests, not LSCache hits. Requests served from the LSCache module do not count against the dynamic request rate limit. This is the correct behaviour — cached responses are cheap — but it means the limit only protects your PHP layer, not your disk I/O or network bandwidth for static file serving.

Setting maxConnections too low starves legitimate users during traffic spikes. A WordPress page load typically opens 4–6 simultaneous connections per browser. With maxConnections 10, a user with multiple tabs open can hit the per-IP limit during a busy page load. Start with 20–30 for WordPress sites and lower only if you are actively mitigating an attack.

Bandwidth throttle does not apply to responses served from the OS kernel’s sendfile path. Static files delivered via sendfile() bypass LiteSpeed’s application-layer throttle in some configurations. If you need hard bandwidth caps on static files, use the context-level throttle directive rather than relying on the global vhost setting.

Connection limit tuning, ban policy review, and integration with Cloudflare rate limiting rules are part of Stack Harbor’s managed operations for production LiteSpeed environments.