php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57756 APC user cache with fcgi processes
Submitted: 2007-07-22 11:57 UTC Modified: 2014-02-28 12:44 UTC
Votes:3
Avg. Score:4.7 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: kurtubba at gmail dot com Assigned: krakjoe (profile)
Status: Closed Package: APC (PECL)
PHP Version: 5.2.1 OS: CentOS
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: kurtubba at gmail dot com
New email:
PHP Version: OS:

 

 [2007-07-22 11:57 UTC] kurtubba at gmail dot com
Description:
------------
using APC with Lighttpd and fcgi; APC is creating more segments so that changing entries on APC user cache would result having different values for every process, I couldn't discover that on my development server but on a high loaded server it creates over 5 different values

Reproduce code:
---------------
#####lighttpd config
fastcgi.server = ( ".php" => ((
"socket" => "/tmp/php.socket-1",
"bin-path" => var.phppath,
"idle-timeout" => 5,
"min-procs" => 1,
"max-procs" => 15,
))
)


#####APC config
extension_dir = /usr/local/lib/
extension = apc.so
apc.shm_segments = 1
apc.shm_size = 1000
apc.ttl = 7200
apc.user_ttl = 7200
apc.num_files_hint = 3000
apc.max_file_size = 2M
apc.stat = 0
apc.include_once_override = 1
apc.mmap_file_mask = /tmp/apc.XXXXXX


####APC store example
if( $apc_var=apc_fetch('var') ){
   apc_store('var',array($apc_var[0],$apc_var[0]+1));
}else{
    apc_store('var',array(time(),$value));
}
print_r(apc_fetch('var'));

Expected result:
----------------
array (
  0 => 1184998359,
  1 => 33189,
)

Actual result:
--------------
array (
  0 => 1184998359,
  1 => 33189,
)
###and
array (
  0 => 1184998404,
  1 => 9858,
)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-22 15:17 UTC] gopalv82 at yahoo dot com
Put an

fprintf(stderr, "%s:%d --> %d got init=%d\n", __FILE__, __LINE__, getpid(), APCG(initialized));

into PHP_MINIT_FUNCTION(apc) in php_apc.c after REGISTER_INI_ENTRIES.

That should give me a better idea of what's happening (sorry, don't quite understand fcgi).
 [2007-07-22 16:03 UTC] kurtubba at gmail dot com
I mean I'm running PHP in fastcgi mode http://www.fastcgi.com
 [2007-11-23 00:44 UTC] seufert at gmai dot com
I have this problem.

Whats happening is you have multiple php processes (with children) running. Each seems to have its own shared memory area. They are not linked in any way.

This is causing me 2 problems, Firstly, say i allow 30mb of ram to be mapped, its multiplied by the number of fast-cgi processes running, so this is basically multiplied by 4 for my configuration.

This is my pstree for lighttpd

init-+-cron
     |-lighttpd(www-data)-+-2*[php5-cgi---php5-cgi]
     |                    `-php5-cgi---php5-cgi---pstree

and that uses 120mb ram, with a 30mb segment size.
 [2008-07-09 02:51 UTC] djonline at djonline dot ru
Is this fixed ?
Why APC not use one Shared Memory Segment for all fastcgi php instancec ?
 [2014-02-28 12:44 UTC] krakjoe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: krakjoe
 [2014-02-28 12:44 UTC] krakjoe@php.net
Closing this bug for several reasons:

 5.2 is no longer supported software.
 APC is no longer the primary means of caching opcodes.
 If the segments are not being shared then it can only be because the processes are not children of the parent that first mapped the memory, only child processes can attach to shared memory by default, it is the only sensible thing to do.

Thanks for helping to make PHP better :)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 11:01:29 2024 UTC