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 -> Other Software View previous topic :: View next topic
Reply to topic   Topic: General performance issues + Error 500 et al
Author
Express



Joined: 07 Jan 2013
Posts: 34

PostPosted: Thu 19 Mar '20 23:35    Post subject: General performance issues + Error 500 et al Reply with quote

I've been doing my best to optimize the performance of my Apache install on Windows, but I'm encountering various issues of generally poor performance and slow page loads all the way through to Error 500 and other 5xx errors.

I'll first give a bit of detail about the host system and my setup, then cover specific configs:
Code:
Intel Xeon E3-1245 v6 @ 3.90ghz (4 core, 8 thread)
32GB DDR4 memory @ 2400mhz (2 x 16GB)
Samsung 480GB Enterprise SATA SSD x 2 (MZ7LM480HMHQ-00005)

Apache VS16 2.4.41 Win64
PHP 7.3.13 NTS x64 (with OpCache enabled and XDebug enabled)

mod_fcgid/2.3.10-dev

Windows Server 2016


The server doesn't exactly do much in terms of anything resource intensive, a couple lightweight server applications but otherwise its basically a web server. Windows Defender is enabled but I have excluded the Apache folder and the PHP folder.

Here are what I assume to be relevant info from my configs:
Code:
Timeout 60
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
UseCanonicalName Off
ServerTokens Prod
HostnameLookups Off

EnableMMap Off
EnableSendfile Off
AcceptFilter http none
AcceptFilter https none


fcgid module config:
Code:
<IfModule fcgid_module>
   FcgidMaxProcesses 300
   FcgidMaxProcessesPerClass 300
   FcgidOutputBufferSize 1073741824
   FcgidMaxRequestLen 1073741824
   FcgidFixPathinfo 0
   FcgidIOTimeout 95
   FcgidBusyScanInterval 100
   FcgidBusyTimeout 95
   FcgidIdleTimeout 60
   FcgidIdleScanInterval 65
   FcgidMinProcessesPerClass 0

   FcgidErrorScanInterval 65

   FcgidConnectTimeout 10
   FcgidProcessLifeTime 0
   FcgidMaxRequestsPerProcess 0
   FcgidZombieScanInterval 20
   FcgidTimeScore 3
   
   #FcgidPassHeader Authorization

   FcgidInitialEnv PHPRC "C:/Core-Servers/PHP"
   FcgidInitialEnv PATH "C:/Core-Servers/PHP;C:\\WINDOWS\\system32;C:\\WINDOWS; C:\\WINDOWS\\System32\\Wbem;"
   FcgidInitialEnv SystemRoot "C:\\Windows"
   FcgidInitialEnv SystemDrive "C:"
   FcgidInitialEnv TEMP "C:\\WINDOWS\\TEMP"
   FcgidInitialEnv TMP "C:\\WINDOWS\\TEMP"
   FcgidInitialEnv windir "C:\\WINDOWS"
   <Files ~ "\.php$">
      Options Indexes FollowSymLinks ExecCGI
      AddHandler fcgid-script .php
      FcgidWrapper "C:/Core-Servers/PHP/php-cgi.exe" .php
   </Files>
</IfModule>


Apache MPM config - I have extensively toyed with this to find something stable:
Code:
<IfModule mpm_winnt_module>
   ThreadLimit        250
    ThreadsPerChild        250
    MaxConnectionsPerChild   0
</IfModule>


Now maybe I have something horrific in my configuration or maybe there is a multitude of smaller errors, but either way let's get onto what I assume to be most relevant - I see these errors being output quite regularly in the logfile at the moment:
Code:
[Thu Mar 19 21:04:41.236271 2020] [fcgid:warn] [pid 11328:tid 5560] [client 2001:982:1578:1:48a5:3082:4e74:2b1c:43408] mod_fcgid: read timeout from pipe, referer: https://forum.aceclan.org/admin/?adsess=SNIP&app=core&module=staff&controller=
[Thu Mar 19 21:04:41.236271 2020] [core:error] [pid 11328:tid 5560] [client 2001:982:1578:1:48a5:3082:4e74:2b1c:43408] End of script output before headers: index.php, referer: https://forum.aceclan.org/admin/?adsess=SNIP&app=core&module=staff&controller=
[Thu Mar 19 21:22:43.470087 2020] [fcgid:warn] [pid 11328:tid 4984] [client 46.69.205.188:58876] mod_fcgid: read timeout from pipe, referer: https://forum.aceclan.org/
[Thu Mar 19 21:22:43.470087 2020] [fcgid:warn] [pid 11328:tid 4984] (138)Unknown error: [client 46.69.205.188:58876] mod_fcgid: ap_pass_brigade failed in handle_request_ipc function, referer: https://forum.aceclan.org/
Back to top
James Blond
Moderator


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

PostPosted: Sun 22 Mar '20 13:48    Post subject: Reply with quote

Did you enable php error log?
Back to top
Otomatic



Joined: 01 Sep 2011
Posts: 212
Location: Paris, France, EU

PostPosted: Tue 24 Mar '20 10:36    Post subject: Re: General performance issues + Error 500 et al Reply with quote

Express wrote:
PHP 7.3.13 NTS x64 (with OpCache enabled and XDebug enabled)

It seems to me that with Apache, under Windows, it is necessary to use TS (Thread Safe) distributions.

- On php.net download page
Which version do I choose?
With Apache you have to use the Thread Safe (TS) versions of PHP.

Same thing for the xDebug version used.
Back to top
Steffen
Moderator


Joined: 15 Oct 2005
Posts: 3092
Location: Hilversum, NL, EU

PostPosted: Tue 24 Mar '20 12:07    Post subject: Reply with quote

TS does not work with mod_fcgid (is @Express using)

Five ways to install PHP with Apache:

1. Apache64 with TS PHP64 and php7_module

2. Apache32 with TS PHP32 and php7_module

3. Apache64 with NTS PHP64 and FCGID64

4. Apache64 with NTS PHP32 and FCGID64

5. Apache32 with NTS PHP32 and FCGID32

We prefer using mod_fcgid.
Back to top
Express



Joined: 07 Jan 2013
Posts: 34

PostPosted: Tue 24 Mar '20 13:43    Post subject: Reply with quote

James Blond wrote:
Did you enable php error log?

This is a split environment with some stuff being in development, so whilst the PHP error log is enabled it is being flooded with errors from other projects, I have read the log and nothing significant stands out to me. Additionally, we are experiencing these issues on pages that do not appear to present any errors in the PHP log.

The only way I found to get errors to log at all is setting "log_errors" to on and specifying a file path for "error_log" which in itself is not ideal.

Otomatic wrote:
It seems to me that with Apache, under Windows, it is necessary to use TS (Thread Safe) distributions.

- On php.net download page
Which version do I choose?
With Apache you have to use the Thread Safe (TS) versions of PHP.

Same thing for the xDebug version used.

I am at a loss as to whether I should use TS or NTS personally, as I see conflicting guidance dependent on where I research it. PHP is loaded via FCGI. Take the same page you refer to for example (https://windows.php.net/) and scroll further down to the "TS and NTS" section it says use NTS if running via FastCGI.
Back to top
Express



Joined: 07 Jan 2013
Posts: 34

PostPosted: Tue 24 Mar '20 13:45    Post subject: Reply with quote

Steffen wrote:
TS does not work with mod_fcgid (is @Express using)

Five ways to install PHP with Apache:

1. Apache64 with TS PHP64 and php7_module

2. Apache32 with TS PHP32 and php7_module

3. Apache64 with NTS PHP64 and FCGID64

4. Apache64 with NTS PHP32 and FCGID64

5. Apache32 with NTS PHP32 and FCGID32

We prefer using mod_fcgid.


Per your list I am using Option 3.
Back to top
Steffen
Moderator


Joined: 15 Oct 2005
Posts: 3092
Location: Hilversum, NL, EU

PostPosted: Tue 24 Mar '20 16:57    Post subject: Reply with quote

@Otomatic Yes, the PHP home page is not that clear, I have asked the PHP team to change it.

Now on http://windows.php.net :

With Apache, using the apache2handler SAPI, you have to use the Thread Safe (TS) versions of PHP.

Was :
With Apache you have to use the Thread Safe (TS) versions of PHP
Back to top
Otomatic



Joined: 01 Sep 2011
Posts: 212
Location: Paris, France, EU

PostPosted: Tue 24 Mar '20 18:21    Post subject: Reply with quote

Steffen wrote:
With Apache, using the apache2handler SAPI, you have to use the Thread Safe (TS) versions of PHP.

Thank you. It's much clearer now.
Back to top
James Blond
Moderator


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

PostPosted: Wed 25 Mar '20 10:00    Post subject: Reply with quote

Steffen wrote:
TS does not work with mod_fcgid


@Steffen:
I use it all the time. Why shouldn't it?
Back to top
Steffen
Moderator


Joined: 15 Oct 2005
Posts: 3092
Location: Hilversum, NL, EU

PostPosted: Wed 25 Mar '20 10:33    Post subject: Reply with quote

Really ? I did not know.

On the php homepage that nts for fcgid:

TS and NTS
TS refers to multithread capable builds. NTS refers to single thread only builds. Use case for TS binaries involves interaction with a multithreaded SAPI and PHP loaded as a module into a web server. For NTS binaries the widespread use case is interaction with a web server through the FastCGI protocol, utilizing no multithreading (but also for example CLI).
Back to top
James Blond
Moderator


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

PostPosted: Wed 25 Mar '20 13:20    Post subject: Reply with quote

The multi thread capability is for the apache php module. The php-cgi works the same. Except that it s thread safe and because of the background checks for that it might be a little slower.
For me it runs fine, since PHP doesn't crash Wink
Back to top
Express



Joined: 07 Jan 2013
Posts: 34

PostPosted: Wed 25 Mar '20 16:15    Post subject: Reply with quote

So given what you're saying then I could run TS or NTS if I wanted to.

I mean the end result of what I am getting though is quite often Error 524 via CloudFlare, which means: https://community.cloudflare.com/t/community-tip-fixing-error-524-a-timeout-occurred/42342
Back to top
James Blond
Moderator


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

PostPosted: Sat 28 Mar '20 15:23    Post subject: Reply with quote

The error message means time out. Does a connection work, if you use a plain html page?

I recommend to use the php error log and check what causes this 500 errors. also check the apache error log.

And yes, you can can run NTS or TS or both. With mod_fcgid you can run different version of different vhosts or directories. For example: I use PHP 7.4 for my main web site, but in a sub folder I run PHP 7.0 for an older PHP software.
Back to top


Reply to topic   Topic: General performance issues + Error 500 et al View previous topic :: View next topic
Post new topic   Forum Index -> Other Software