8

We have a PHP web application we are deploying to a LAMP server running CentOS 5.5 using Capistrano. Capistrano manages switching to the latest version (and rolling back) using a symlink, so our document root has to point to that symlink.

Unfortunately, we have been seeing that web requests to the PHP application still point to the previous target of the document root's symlink for exactly 60 seconds after the symlink is updated.

The only setting in the PHP config I could find that might relate to this is the realpath_cache_ttl setting, however this is set to 120 seconds. I couldn't find anything in apache's configuration.

We are not using APC.

Am I even looking in the right place?

nlo
  • 341
  • 2
  • 3
Shabbyrobe
  • 557
  • 1
  • 7
  • 19

4 Answers4

11

Symlinks are cached by Apache, I assume you are using FollowSymLinks in your httpd.conf. You could try using SymLinksIfOwnerMatch whose call to lstat is not cached http://httpd.apache.org/docs/2.0/misc/perf-tuning.html#symlinks

Ochoto
  • 1,174
  • 7
  • 12
1

In my case, it was not Apache itself. I had to restart php-fpm.

Stuggi
  • 3,366
  • 4
  • 17
  • 34
user1383029
  • 111
  • 1
1

apache doesn't cache symlinks but it caches locations of files a bit and if you use APC it will really do some caching. I saw this also but used fabric for deploys. The work around was doing a apache restart/reload/graceful after the change symlink.

try a graceful first, then reload then restart if all else fails

Mike
  • 21,910
  • 7
  • 55
  • 79
  • 1
    Can apache be told to do any of those things when not running as root/sudo? It is not an option for me to sudo during routine capistrano deploys. – Shabbyrobe Jul 26 '11 at 23:02
  • 1
    You need to work with your sysadmin to devise a solution for this. – sciurus Aug 05 '11 at 18:44
0

Apache doesn't cache symlinks (it'd be incredibly stupid to try; the filesystem cache knows a lot more about what's going on, and would be very close to as fast). I'd strace the whole shebang to get a better idea of what's doing what when.

womble
  • 95,029
  • 29
  • 173
  • 228
  • 1
    What does strace do exactly? Is it safe to run in production? This is a classic "happens in production only" issue. – Shabbyrobe Jul 26 '11 at 23:01
  • 2
    Questions go in questions, not comments. But really, `man strace` isn't hard. – womble Jul 26 '11 at 23:08
  • 1
    `$ man strace No manual entry for strace`. It's not available on my production systems. Requests for elaboration on your solution go in comments. – Shabbyrobe Aug 02 '11 at 04:30
  • "Is strace safe to run in production?" and "What does strace do exactly?" aren't requests for elaboration, they're completely separate questions. – womble Aug 02 '11 at 09:17
  • It's a moot point - it's not available on the system where the problem is occurring anyway. Do you have any other ideas? – Shabbyrobe Aug 03 '11 at 05:02
  • 1
    Install strace. – womble Aug 03 '11 at 07:42
  • That isn't an option. I don't have control over the packages that are installed on this server. I can tinker with the configuration though. – Shabbyrobe Aug 03 '11 at 07:47
  • 2
    If you don't have root, you can't properly diagnose the problem anyway, so hand this over to the sysadmin to deal with. However, you don't need root to install software. – womble Aug 03 '11 at 07:56