Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a Debian machine where I use both apache2 (with mod_proxy) and Lighttpd (for a long-polling service and static contents).

Both apache and lighttpd run php5, with APC.

Lighttp use FastCGI for php5.

Now, both environment works well, but the APC cache are separated, is there a way to tell lighttpd and apache to use the same APC cache?

Example of what I want to obtain:

//example.com, served by apache2:
<?php
apc_add('foo', 'bar');
echo apc_fetch('foo');
//output: bar
?>

//polling.example.com, served by lighttpd:
<?php
echo apc_fetch('foo');
//output desired: bar
//actual output: nothing!
?>

p.s: I think this belongs to server fault, if not, I'll post on Stackoverflow.

EDIT: After reading the answer from Dan, and searching also on stackoverflow, it's clear that at the moment APC cache CAN'T BE SHARED, when someone need this point, another cache system must be chosen (as memcache, that is slower than APC

Feel free to close this question if considered a SO duplicate.

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

I don't know if the APC cache can be shared between multiple (FastCGI) PHP instances, but maybe memcached or a similar program could solve your problem. You'd have to change your PHP scripts, though.

share|improve this answer
    
I still have to write my php scripts, im still in 'project phase' ;) –  Strae Nov 27 '09 at 12:02
add comment

Based on the information in this outstanding PECL feature request ticket for APC, about sharing cache data and locks between multiple FCGI processes in the same httpd environment, I would say it's also not possible to do between multiple httpd environments.

Edit to add:

You would still receive some benefit from using APC. The initial results after daemons have spun up might not be great, but over time the cache for each process will become seeded and reused. memcache and APC perform similar functions in as such they "cache information", but their actual purposes are quite different. memcache is a key-value cache for data and APC is an opcode cache for code.

share|improve this answer
    
Damn, seem like i have to switch to memcache. –  Strae Nov 27 '09 at 11:51
    
I'll figured out how to use them both, for different things! –  Strae Dec 17 '09 at 21:34
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.