0

I run my website on an apache server and I noticed something interesting and I have discovered it through testing with apache bench.

The page I'm testing is the IP address my server runs on and that would return a redirect to an actual website hosted on the same server. The output before the redirect is about 50 bytes of data.

While web browsers happily redirect, I played the role of a bad actor by testing the same page with different connection settings and NO keep alive.

Here are results of the craziest tests....

results

I did notice the numbers were mildly high (in the 200ms ballpark) if I used 50 connections instead (changing -n200 to -n50) and that's likely why google pagespeed insights on a rare occasion reports a high TBT on a simple webpage with no external components and hardly any inline javascript or CSS.

I did limit the maximum number of connections on my server to HTTP and HTTPS with IPtables but I don't know the perfect limit to apply because I want google and other search engines to crawl my site without a problem. If I don't apply a limit, then people who connect to my site with keep-alives disabled could make the site loading time high.

1 Answer 1

0

For Apache, there are 3 settings that control KeepAlive behavior:

  • KeepAlive
  • KeepAliveTimeout
  • MaxKeepAliveRequests

The first one just turns on or off the ability to use KeepAlive.

The second one controls how many seconds (or milliseconds) to wait before dropping a connection. This one is critical, as setting it up too high, and your server can suffer when coming under stress from multiple connections, as it will keep them open waiting for another request. Too low, and you won't be really harnessing the benefits of KeepAlive.

The third one controls how many requests per connection to allow.

Apache Manual

Since you are already testing, try to tune your KeepAliveTimeout to say, 2 or 1 seconds and retest to see if your results are better.

1
  • I played with that and I already have KeepAliveTimeout set to 2. My question is more geared on someone connecting to the server without keepalive enabled on the client side. Commented Nov 18, 2024 at 20:17

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.