We have webservers running nginx 7.65 along with fastcgi PHP5 and are looking into caching possibilities to speed up content delivery and lower system loads. The servers run different (custom) applications.
There are so much options for caching I am not sure what would be a sane setup. There is memcached, APC, Nginx' fastcgi_cache, proxy_cache....
I know memcached has the distributed ability as bonus but we do not need it at this point. In my experience memcached performs slower than APC if installed on the same machine as it is serving for, but this was some time ago.
I am not familiar with the Nginx fastcgi_cache or even the regular proxy_cache module. Is it comparable or is it something completely different?
What would be a good, sane caching method for Nginx w. FastCGI PHP5?
If your box can handle the entire cache on its own, memcache will only slow you down. APC is shared memory. Used right it will blow away memcached. Nginx fast cgi cache will make all dynamic php pages scream. Even if you set the cache to just 10 seconds, this makes it such that that max hit rate to any given php page will be once every 10 seconds. Makes it impossible to crash a page with load. I run a bunch of websites on a single small box that gets millions of people per month. All you need is nginx caching and APC at this point.
Memcache comes into the picture only when you have to scale your cache beyond a single box.
http://php-fpm.org/ is what we've used on a few recent installations rather than FastCGI itself.
Nginx can serve pages right from memcached, so, your application could write the pages direct to memcached. Otherwise, you'd need to make sure your code utilized memcached for queries/objects. An opcode cache will help depending on your codebase. If you have a small set of scripts that are repeatedly run, APC or XCache (or eaccelerator in some cases) can provide a nice boost.
Your caching method is determined by your code. Can you cache pages? fragments? sql results? values? What is the lifetime of those entities, how much space do they need, how large is the key and result set? As for memcached being slower than APC, since they don't really perform the same task, I'm not sure what you compared.
IMHO we sysadmins tend to focus on this problem backwards, starting at the back end, because thats our turf. The most effective stuff is really at the front end. If you can get the browser cache (http headers) and http cache (cdn, headers again) part right you can do astonishingly sloppy things at origin and be fine.
Nowadays you can substitute PHP-FPM with HHVM which will combine the performance of PHP-FPM + APC and gives you amazing speeds: hhvm+nginx+fastcgi_cache