php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57588 Stress Testing with ApacheBench when APC is enabled makes Apache 2.2.4 crashes
Submitted: 2007-03-25 06:01 UTC Modified: 2013-02-18 00:35 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: pcdinh at gmail dot com Assigned: pajoye (profile)
Status: No Feedback Package: APC (PECL)
PHP Version: 5.2.1 OS: Windows XP SP 2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
9 + 23 = ?
Subscribe to this entry?

 
 [2007-03-25 06:01 UTC] pcdinh at gmail dot com
Description:
------------
APC makes Apache 2.2.4 unusable, immediately crashed when performing stress test with Apache Bench.

Testing with my framework and Zend Framework

Reproduce code:
---------------
I try to make a benchmark with Zend Framework using Rob code
http://akrabat.com/wp-content/uploads/zf-tutorial_130.zip

Batch code:
@ECHO OFF
ECHO Apache Bench Ready.
c:\server\apache2.2\bin\ab -t 60 -c 20 http://localhost/iphilia/zend/
PAUSE

APC config
[APC]
apc.enabled=1
apc.shm_segments=1
apc.shm_size=64
apc.optimization=0
apc.num_files_hint=1000
apc.ttl=0
apc.gc_ttl=3600
apc.cache_by_default=On
apc.slam_defense=0
apc.file_update_protection=2
apc.enable_cli=0
apc.stat=0 

Expected result:
----------------
The benchmark should be done smoothly with APC-enabled. Actually, when APC is disabled, no error occurs

Actual result:
--------------
Apache 2.2.4 crashed immediately.

Apache error.log said

[Sun Mar 25 17:46:07 2007] [notice] Apache/2.2.4 (Win32) PHP/5.2.1 configured -- resuming normal operations
[Sun Mar 25 17:46:07 2007] [notice] Server built: Jan  9 2007 23:17:20
[Sun Mar 25 17:46:07 2007] [notice] Parent: Created child process 496
[Sun Mar 25 17:46:07 2007] [notice] Child 496: Child process is running
[Sun Mar 25 17:46:07 2007] [notice] Child 496: Acquired the start mutex.
[Sun Mar 25 17:46:07 2007] [notice] Child 496: Starting 250 worker threads.
[Sun Mar 25 17:46:08 2007] [notice] Child 496: Starting thread to listen on port 80.
[Sun Mar 25 17:46:20 2007] [apc-error] Cannot redeclare class zend_registry
Error in my_thread_global_end(): 252 threads didn't exit


When testing APC with my OOP classes, APC causes this kind of error: Cannot redeclare class [class_name_here]. When I disable APC, this kind of error does not occur

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-26 02:57 UTC] gopalv82 at yahoo dot com
apc.stat = 0 cannot be used with TSRM mode due to a few quirks in current implementation.

I'll take a closer look at the class redeclare error assuming it is happening in php5 ?

The error is due to the weirdness in class naming/mangling that zend does internally. Everytime Zend compiles a file, it generates a new & unique internal name - which APC cannot duplicate because it serves out the same opcode dump for every request. So multiple inclusion of the same file or code like 

if(class_exists('x')) { class x {} }

and even combinations of __autoload based class loading can cause such anomalies. I'm trying to document such APC gotchas, but the issues generally show up only at high load and debugging it is mostly guesswork.
 [2007-06-23 00:13 UTC] edwardhey at 163 dot com
also encountered the same problem...how to solve?
 [2007-06-23 04:26 UTC] rasmus@php.net
Don't use a threaded mpm.  There are too many moving parts between all the external libraries and APC for it to be a robust platform.  It is also always going to be slower on a per-request basis.  You are better off using prefork and lowering the number of concurrent connections per frontend machine.  To lower your latency numbers you want to finish requests as fast as possible and you do that by having more frontend machines with fewer concurrent requests per machine.
 [2008-09-17 10:48 UTC] david at palepurple dot co dot uk
I've just encountered this bug on a development system running Ubuntu Hardy with PHP 5.2.6 and APC from dotdeb.org.

In my case, I saw : "[apc-error] Cannot redeclare class zend_exception" in my Apache error log file. 

Restarting Apache fixed it for me :-/
 [2008-09-17 11:09 UTC] rasmus@php.net
A redeclared class may not be a bug, actually.  APC caches top-level functions and classes which ends up suppressing the redeclaration warnings you would normally get if you declare the same class twice, usually by including the file the class is declared in, multiple times.  However, when the cache fills up and we need to purge things, the cache is locked during this cleanup phase and scripts go back to running uncached, and in the uncached mode these redeclaration warnings come back.

So, try turning off APC and see if you see this warning.  If you do, then it definitely isn't an APC issue.
 [2011-04-13 19:09 UTC] pierre dot php at gmail dot com
Please try using 3.1.8 and 5.3.6 using the binaries from 
http://www.php.net/~pierre/
 [2013-02-18 00:35 UTC] pecl-dev at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 23:01:28 2024 UTC