0

See my APC here: http://www.animefushigi.com/apc.php

If you keep hitting the Refresh button on the top left, watch the number of "Hits" and the "Start Time" and "Uptime" values. They all go up and down.

I find this quite strange, normally all 3 of these values should only get higher as time passes, not go down (except Start Time - which should stay the same)

My only assumption is that the cache is being flushed every second.

I've searched around and have tried a few things to fix this

  • disabled suEXEC
  • set apc.mmap_file_mask /dev/zero
  • tried PHP 5 Handler fcgi and cgi

also when I go to /tmp/ on ssh and do -ls I don't see anything apc related.

Any suggestions ?

The server is linux and uses whm/cpanel

*edit: I have a suspicion that the problem may be due to apc.mmap_file_mask. Currently it's set to /tmp/apc-animefus.XXXXXX but on the apc.php page it seems the xxxxxx is replaced on every refresh to something else

masegaloeh
  • 17,978
  • 9
  • 56
  • 104
Greatestswordsman
  • 387
  • 1
  • 5
  • 17

1 Answers1

2

Some notes about APC and the different modes:

  • APC's cache is essentially per-process.
  • If you use CGI, the process is created, APC creates its cache, and then the process ends and the cache clears. (from what I can find, suPHP seems to be CGI-like).
  • If you use FastCGI, Apache spawns one process for each simultaneous request. It keeps them around in case they'll be used again. Each process has its own APC cache.
  • If you use the mod_php handler, it shares the cache among all the apache processes, but doesn't run it as the user.

Observations:

  • The cache is not resetting on every page refresh, I am seeing several that are being reused that are now five minutes old. Any reconfiguring of the server would've reset this.
  • The only way to know you get the same FastCGI process is to be the only client.
  • There may be so many requests on your website, that there are several FastCGI processes in use.

Things that should be true:

  • While in CGI or SUPHP mode, the values never go up.
  • While in fcgid mode, the values go up and down.
  • While in mod_php/DSO mode, the values are correct.

Things I'd check (not in any particular order):

  • Watch PHP processes under your user (using top or similar). See how long they typically run and if they exit.
  • Check Log files to see how many requests is hitting PHP.
  • Create a script to check the process ID that the script is run as, if you like write them to a database/file so you can keep track of them easily. Keep loading this page to gather information about how long the process runs.
  • Check FastCGI configuration, I'm not sure how cPanel configures it by default because it always had a few issues with some websites when I tried it. There are several options that control how long a process should stay alive. PHP, by default, will exit after 500 requests in FastCGI mode. This is purposeful as some have reported PHP leaking memory after running for a very long time. If your site gets a lot of hits, you may want to bump this number up.
Reece45
  • 709
  • 4
  • 15
  • Please go to the following link, and click the "Refresh" button at the top left about 5 times. Watch the column that says "Created at". The times go forward and back. http://www.animefushigi.com/apc.php?SCOPE=A&SORT1=H&SORT2=D&COUNT=20&OB=2&SH= – Greatestswordsman Feb 03 '12 at 20:16
  • @Greatestswordsman As I stated above, that's because its in fcgid mode and is likely changing processes between the different requests. The Start Time, and changes most of the time, but it does not change every time. Sometimes it uses a value it used previously. You might notice a few hundred requests from a particular IP address-- they do repeat themselves. – Reece45 Feb 03 '12 at 23:57