[Info-vax] Apache + mod_php performance

Dan Cross cross at spitfire.i.gajendra.net
Wed Sep 25 14:41:17 EDT 2024


In article <vd1bdp$3npm3$1 at dont-email.me>,
Arne Vajhøj  <arne at vajhoej.dk> wrote:
>On 9/25/2024 8:48 AM, Dan Cross wrote:
>[snip]
>>> Just executing the same PHP code in a loop give much higher
>>> performance.
>>>
>>> Single process : 158 executions per second = 9480 executions per minute
>>>
>>> And multi process could probably get significantly higher.
>> 
>> So this suggests that your PHP code, by itself, is not the
>> bottleneck,
>
>The PHP code is very simple: read 3 rows from a database table
>and output 35 lines of HTML.
>
>>              though it remains unclear to me what you mean when
>> you say, "just executing the same PHP code in a loop...": does
>> this mean that you're running the PHP interpreter itself in a
>> loop?  As in, starting it fresh on every iteration?  Or does
>> this mean that you've got a loop inside the PHP program that
>> runs your test and you're measuring the throughput of that?  And
>> is this standalone, or executed under the web framework?  That
>> is, are you running this under Apache and hitting some query
>> that then causes the PHP interpreter to repeatedly query the
>> database?
>
>PHP script with a loop executing the same code as the web
>request inside the loop. PHP script run command line.
>No Apache or mod_php involved.

So PHP talking to your database seems fine, then.

>>>> With no further details, I'd wonder if you're not caching
>>>> connections to the database between queries.
>>>
>>> Does not matter.
>> 
>> Surely it does.  If, for whatever reason, you're not holding
>> onto the connection to the database between queries, but rather,
>> re-establishing it each time, that will obviously have overhead
>> that will impact performance.
>> 
>> Or perhaps you're saying this because of some unstated
>> assumption alluded to in the questions above?
>
>I am saying this because the numbers were the same. 11 req/sec
>in both cases.

Oh, I see what you mean now.  That was a statement of fact based
on your findings, not an assertion.  Sorry, I missed your "db
con pool" numbers in your previous post.

>>> I just found out that Tomcat+Quercus numbers get even higher
>>> after some warmup.
>>>
>>>                      no db con pool    db con pool
>>> Apache + CGI              4              N/A
>>> Apache + mod_php         11               11
>>> Tomcat + Quercus        208              214
>> 
>> That's nice, but that seems irrelevant to the question of why
>> PHP under Apache is so slow.
>
>You brought up the topic, so I tested.

Hmm, I just went back and looked at the thread, and I don't see
where I asked about Tomcat/Quercus.

>> Perhaps a simpler question: what sort of throughput does Apache
>> on VMS give you if you just hit a simple static resource
>> repeatedly?
>
>Now it becomes interesting.
>
>nop.php also gives 11 req/sec.
>
>And nop.txt also gives 11 req/sec.
>
>So the arrow is definitely pointing towards Apache.

I should think so.  Lesson #1: always verify your base
assumptions when investigating something like this.

>So either something to speed up Apache or switching to WASD or OSU.

Well, the question now becomes, "what makes Apache so slow?"

I would concentrate on your nop.txt test; I assume that's a
small (possibly empty) text file and as an example has the
fewest number of variables.

Do your logs give any indications of what might be going on?
For example, do the logs have host names in them, possibly
implying your stalling on reverse DNS lookups or something
similar?

	- Dan C.



More information about the Info-vax mailing list