logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Apache hitting brick wall serving static content
Author
jimski



Joined: 18 Jan 2014
Posts: 196
Location: USSA

PostPosted: Thu 19 Nov '15 14:13    Post subject: Apache hitting brick wall serving static content Reply with quote

Problem:
When testing Apache 2.4.16 on windows 8 over 10Gb/s network there is a severe limitation when serving static content. Apache can't serve more than 400 concurrent requests for static content with Keep Alive OFF.

siege -b -c700 -t10s -v http://10.0.0.31/100k.jpg
ERROR
socket: 2039797504 connection refused.: Connection refused

I also tried apache bench and weighttpd with the same results
ab -c 700 -n 10000 http://10.0.0.31/100k.jpg (100KB file)
ERROR:
apr_socket_recv: Connection refused

However when testing with apache bench on the localhost (bypassing the network) apache works fine and can serve 1000 concurrent requests for 100K static file.

Apache has ThreadsPerChild 7000 (increasing it to 14000 didn't make any difference)
MaxConnectionsPerChild 0

My load testing server is Linux on a separate server and sends requests over the network to Apache Windows server.

Conclusions:
There are no errors in the apache log and nothing in the systen logs. The tasklist doesn't show anything unusual.
netstat shows about 1,000 of open TCP connections and then Apache stops responding. However when testing with lower concurrency of 300 then the OS can open tens of thousands of TCP connections and Apache works fine.

At first I thought this is OS stack tuning problem but serving php file with the same concurrency works fine. ab -c 700 -n 10000 http://10.0.0.31/phpinfo.php

Then I tried Nginx for windows on the same machine
and Nginx served this without a problem ab -c 700 -n 10000 http://10.0.0.31/100k.jpg Nginx was able to serve much higher concurrency up to 5000 requests per second (static content) and the OS opened about 40,000 TCP connections which is about the same as the number of ephemeral ports configured on my system.

The most I can get from Apache is concurrency of 400 on 100KB static file.

So this looks to me like a bug or a limitation in the way Apache communicates with the TCP/IP stack on windows.
Other people also reported similar problems. https://www.apachelounge.com/viewtopic.php?t=6021

Can you guys confirm this on your servers.

Just make sure Keep Alive is OFF and test it over the network (not on localhost). Also be aware that some older versions of Apache Bench have a problem with concurrency in excess of 300. So siege, weighttp may be better for this test.


Last edited by jimski on Fri 20 Nov '15 11:05; edited 3 times in total
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Thu 19 Nov '15 16:37    Post subject: Reply with quote

I had an issue when I tried to set a higher value for ThreadspertChild

What worked was
Code:

    ThreadsPerChild        1748
    MaxConnectionsPerChild   0


Code:
ab -c 700 -n 10000 http://127.0.0.1/1kb.txt


Code:

C:\Users\james\Apache25\bin>ab -c 700 -n 10000 http://127.0.0.1/file.txt
This is ApacheBench, Version 2.3 <$Revision: 1661913 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        Apache/2.5.0-dev
Server Hostname:        127.0.0.1
Server Port:            80

Document Path:          /file.txt
Document Length:        649 bytes

Concurrency Level:      700
Time taken for tests:   52.103 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      9360000 bytes
HTML transferred:       6490000 bytes
Requests per second:    191.93 [#/sec] (mean)
Time per request:       3647.208 [ms] (mean)
Time per request:       5.210 [ms] (mean, across all concurrent requests)
Transfer rate:          175.43 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.3      0       8
Processing:     2 3610 4171.3   2274   49925
Waiting:        1 3608 4172.5   2274   49925
Total:          2 3610 4171.3   2274   49925

Percentage of the requests served within a certain time (ms)
  50%   2274
  66%   3872
  75%   5125
  80%   6140
  90%   9070
  95%  11898
  98%  15701
  99%  18624
 100%  49925 (longest request)

Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Thu 19 Nov '15 16:48    Post subject: Reply with quote

However, I wonder why it is so often nginx vs apache instead of nginx plus apache

Why not

nginx<--->apache+php
or
nginx<--->apache+fcgid<--->PHP
or
nginx<--->apache<--->Tomcat


For a bigger client I use

Code:

                                       |--->Apache+fcgid<--->PHP
                     |------- nginx<---|
                     |                 |--->Apache+fcgid<--->PHP
Loadbalancer    <--->|                 
                     |                 |--->Apache+fcgid<--->PHP
                     |------- nginx<---|
                                       |--->Apache+fcgid<--->PHP
Back to top
jimski



Joined: 18 Jan 2014
Posts: 196
Location: USSA

PostPosted: Thu 19 Nov '15 18:03    Post subject: Reply with quote

Hi James, thanks for the comment but you are testing on the localhost however the problem only appears over the network.
Quote:
ab -c 700 -n 10000 http://127.0.0.1/1kb.txt
Please test it over the network.

I tried your suggestion about reducing threads but it didn't help.
Quote:
ThreadsPerChild 1748


Quote:
However, I wonder why it is so often nginx vs apache instead of nginx plus apache
I used Nginx only to confirm that my OS and TCP stack are OK and not to counterpose it against Apache. I believe that Apache should be able to do much better than 400 concurrent request on static content over the network.

I have been critical of Apache on windows in the past but recent improvements to fcgid and Apache 2.4 have made it a very stable webserver on windows. I can serve 3,500 php requests per sec on a vps with a rock solid performance and no crashing.

But serving static content with high concurrency is a problem. Again, for testing I turned OFF Keep Alive to simulate behavior of users connecting from different IP addresses, as they would start new TCP connection for each new IP address connected to the server.


Last edited by jimski on Fri 20 Nov '15 10:57; edited 1 time in total
Back to top
jimski



Joined: 18 Jan 2014
Posts: 196
Location: USSA

PostPosted: Fri 20 Nov '15 10:51    Post subject: Reply with quote

If you are on 1Gb/s network then try smaller test file of 10KB but with higher concurrency, for example 1000.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Fri 20 Nov '15 17:19    Post subject: Reply with quote

Host win 10 with the 2.5.x-dev version of apache and the client with ab.exe Win7
I'm on the host connected with RDP to the client.

Code:

ab -c 700 -n 10000 http://172.17.25.152/alte_adp_logs.txt


( access log disbaled)

The first 2000 connections where made in almost no time and then it slowed down.

result one http://pastebin.com/p2EM47VJ

second time with -n 2000
http://pastebin.com/HhZRBw3X
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Fri 20 Nov '15 17:33    Post subject: Reply with quote

I tried to increase the value, but then I get

Code:


<IfModule mpm_winnt_module>
ThreadsPerChild 1920
ThreadLimit 2000
MaxConnectionsPerChild 0
</IfModule>

Code:

[Fri Nov 20 16:31:38.723439 2015] [mpm_winnt:crit] [pid 21632:tid 656] (OS 8)Unrecognized Win32 error code 8: AH00355: Child: CreateThread failed. Unable to create all worker threads. Created 1757 of the 1920 threads requested with the ThreadsPerChild configuration directive.


That is PITA
Back to top
jimski



Joined: 18 Jan 2014
Posts: 196
Location: USSA

PostPosted: Sat 21 Nov '15 13:44    Post subject: Reply with quote

I see the same problem as you on windows 10. First few thousand transactions go through and then major slow down with requests taking up to 10 seconds to be processed. Increasing threads makes no difference. Operating system has plenty of ephemeral ports available and Apache still chokes.

On window 8 I see different symptoms. Either Apache immediately chokes with high concurrency or a few thousand requests go through and then connections are completely refused.

Because this is so severe with static content it is most likely an issue related to the way Apache core communicates with the TCP stack on windows.


Last edited by jimski on Mon 07 Dec '15 8:28; edited 1 time in total
Back to top
jimski



Joined: 18 Jan 2014
Posts: 196
Location: USSA

PostPosted: Sun 06 Dec '15 21:08    Post subject: Reply with quote

THE SOLUTION

Covener replied to my post on stackoverflow and wrote this:
Quote:
try disabling mmap, keepalive, or the win32 accept filter in httpd.conf? Those change how it talks to the network stack.


1. I tried changing mmap but it didn't produce any result.
2. Keep Alive needs to be OFF to simulate large number of users connecting from different IPs.
3. However setting AcceptFiler http to none greatly improved the ability of Apache on windows to server static content. Now Apache can serve concurrency of 2000 or higher without a problem until it runs out of ephemeral ports. And that is what we should expect form a good webserver.

So it was a problem with how Apache communicated with TCP stack but it wasn't a bug.
Back to top


Reply to topic   Topic: Apache hitting brick wall serving static content View previous topic :: View next topic
Post new topic   Forum Index -> Apache