2

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.

Strae
  • 457
  • 1
  • 8
  • 22

2 Answers2

1

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.

Dan Carley
  • 25,617
  • 5
  • 53
  • 70
1

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.

joschi
  • 21,387
  • 3
  • 47
  • 50