Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Seriously speeding up PHP?

I've been writing PHP for years, and have used every framework under the sun, but one thing has always bugged me... and that's that the whole bloody thing has to be interpreted and executed every time someone tells my server they want the page served.

I've experimented with caching, FastCGI, the Zend Job Queue (and symfony plug-ins that do similar - as well as my own DB-based solutions that implement the System_Daemon class to run background processes) and I've managed to make my apps fairly quick using all that stuff... but I can't get over the mental block that my settings files, system/environment check functions, and all the stuff that should only really be loaded ONCE... loads every darn time someone hits my page.

So, my ramble leads to the following Q--

Is there some method/technique for loading certain aspects of PHP into RAM so that when that page is requested, all my settings.yml files, system checks, framework files, cached pages etc can be loaded directly from memory without ever even touching the HD... or needing to go through the same loading mechanism 50,000 times per day to init the program?

If there's nothing in PHP... are there any other 'web' languages that can be compiled in this way, to allow for true init-once apps?

like image 633
Lee Benson Avatar asked Nov 21 '09 08:11

Lee Benson


2 Answers

I think you should give memcached a try, if you're talking about caching data. I think PHP is fairly proficient in caching compiled php-pages if you use stuff like mod_php in apache (which doesn't die in between requests).

like image 147
falstro Avatar answered Sep 28 '22 08:09

falstro


Take a look on APC (Alternative PHP Cache), it keeps a cache of compiled files (PHP Opcode) and also lets you store random variables on memory with apc_fetch, apc_store.

The instalation is very simple and it really gives a boost on performance.

like image 30
Felipe Ribeiro Avatar answered Sep 28 '22 08:09

Felipe Ribeiro