A have setup an interior proxy type of factor using Curl and PHP. The setup is much like this:

The proxy server is really a rather cheap VPS (that has slow disk i/o sometimes). All demands for this server are addressed by just one index.php script. The index.php brings data from another, fast server and shows towards the user.

The information transfer between your two servers becomes manifest pretty quickly and also the bottleneck is simply the disk i/o around the proxy server. Since there's just one index.php - I wish to know

1) How do you make sure that index.php is permanently "cahced" in Apache around the proxy server? (Searching for php cache, I discovered many custom solutions which will cache the "data" output by php I wish to determine if you will find any pre-build modules in apache which will cache the php-script itself?).

2) May be the data fetched in the after sales server alway within the RAM/cache around the proxy server? (presuming there's enough memory)

3) Does apache read any config files or any other files from disk when handling demands?

4) Does apache watch for logs to become written to disk before serving this content - if that's the case I'll disable logging around the proxy server (or perhaps is there method to ensure submissions are first offered without awaiting logs to become written).?

Essentially, I wish to eliminate disk i/o altogether around the 'proxy' server.



1) Install APC (http://pecl.php.internet/apc), this can compile your PHP script once and it in shared memory for that duration of the webserver process (or perhaps a given TTL).

2) In case your script brings data and doesn't cache/store it around the filesystem, it will likely be in RAM, yes. Only throughout the request. PHP utilizes a 'share-nothing' strategy meaning -all- memory is launched following a request. Should you choose cache data around the filesystem, think about using memcached (http://memcached.org/) rather to bypass file i/o.

3) For those who have .htaccess support triggered, Apache will look for individuals in every path resulting in your php file. See Why can't I disable .htaccess in Apache? for more information.

4) Not 100% sure, however it most likely does wait.

Why don't you use something similar to Varnish that is clearly designed for this kind of task and doesn't carry the overhead of Apache?

I would suggest "tinyproxy" with this puprose. Does all you want very efficeintly.