Just installed APC on our server (Alternative PHP Cache - http://uk2.php.net/manual/en/book.apc.php) and already seeing some great improvements in page load times/CPU usage per request. Particularly good for us as we're using Propel with lots of DB tables so already have 570+ .php files in the cache.<p>Any recommendations/gotchas, or should everything be fine out-the-box?<p>And while we're on the subject, what other recommendations have people got for speeding up/optimising PHP/LAMP?
There is no right answer. Despite what others say, php is perfectly suited for a lot of needs. Runtime may be your issue, but you also have to think of supportability.<p>If your looking to optimize your site, as messenlinx suggested yslow is a good place to start. Next, I would suggest looking at your queries, ie a select statement across a big table vs. a more refined query across a smaller data set will do wonders regardless of the language.<p>If your data is updated infrequently, you can look at caching your queries in the data level. If not, maybe look at memcached?
APC is very nice because you can really plug it in and expect to get performance improvements without any “real work.” That said, it really depends on your architecture and the traffic/usage patterns you expect.
Do you get more reads? more writes? Do you use InnoDb or MyISAM?<p>Do you have a cache policy? For files? For DB data?
Do you use the APC user cache or Memcached? The APC user cache is faster (on the web front-end), but is not shared. Memcached is shared but there will always be small network latency.
If DB access is a bottleneck, consider using a data cache.<p>Do you serve a lot of static files? Consider using a CDN (not a silver bullet! There are drawbacks.)<p>There are a lot of strategies for high performance on <a href="http://highscalability.com/" rel="nofollow">http://highscalability.com/</a> . But don't overdo it! Most of the time you don't need to set up your infrastructure to be scalable for millions of clients.<p>As missenlinx pointed out, try also to speed up the page display by following Yahoo! recommendations on <a href="http://developer.yahoo.com/performance/rules.html" rel="nofollow">http://developer.yahoo.com/performance/rules.html</a> ; The number of requests per page is certainly something that made a difference when optimized, at least in my experience - YMMV.
<i>what other recommendations have people got for speeding up/optimising PHP</i><p>Use a different programming language.<p>No, seriously. <a href="http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&lang=php&lang2=ocaml" rel="nofollow">http://shootout.alioth.debian.org/gp4/benchmark.php?test=all...</a><p>If runtime speed is your design goal, then you definitely want to think outside the PHP/Perl/Python/Ruby box. Those are fast enough for most people, but other languages are <i>a lot</i> faster. OCaml and Haskell are amazing; SBCL is pretty good too.
Best page i've seen around<p><a href="http://developer.yahoo.com/performance/rules.html" rel="nofollow">http://developer.yahoo.com/performance/rules.html</a>