realpath_cache for owncloud code base not working
Expected behaviour
if you synch files, the number of stats should be kept as low as possible (in this case most liklely by using/enabling/configuring the REALPATH_CACHE for looking up paths insteas of using stat, lstat etc over and over
Actual behaviour (not yet re-enacted by support):
Customer has a huge number of lstats into the /var/www/html/owncloud tree This introduces a very high overhead for each request. The customers machine shows: The number of stats (stat, lstat, open) into /boxstorage is close to 400 instead of being at maximum 20 or 40. This is killing storage backends over the network (# of files see below)
Steps to reproduce
- have 20 files in the top-level directory
- sync them to an empty directory
- pure download test - no upload
Server configuration
Operating system: redhat 6
Web server:
Database: apache2
PHP version: php 5.4
ownCloud version: 5.0.14 EE
more info aubout the customer server is to come
Realpath cache can be enabled and configured in php.ini - not within our responsibility.
What we should analyse is the amount of stat calls itself.
Fight the cause not the symptom
Von Samsung Mobile gesendet
-------- Ursprüngliche Nachricht -------- Von: dietmaroc [email protected] Datum:10.01.2014 13:50 (GMT+01:00) An: owncloud/core [email protected] Betreff: [core] realpath_cache for owncloud code base not working (#6710)
Expected behaviour
if you synch files, the number of stats should be kept as low as possible (in this case most liklely by using/enabling/configuring the REALPATH_CACHE for looking up paths insteas of using stat, lstat etc over and over
Actual behaviour (not yet re-enacted by support):
Customer has a huge number of lstats into the /var/www/html/owncloud tree This introduces a very high overhead for each request. The customers machine shows: The number of stats (stat, lstat, open) into /boxstorage is close to 400 instead of being at maximum 20 or 40. This is killing storage backends over the network (# of files see below)
Steps to reproduce
have 20 files in the top-level directory sync them to an empty directory pure download test - no upload Server configuration
Operating system: redhat 6
Web server:
Database: apache2
PHP version: php 5.4
ownCloud version: 5.0.14 EE
more info aubout the customer server is to come
— Reply to this email directly or view it on GitHub.
By default realpath_cache_size is set to 16k. You can check the realpath cache usage by adding a line like
<!-- cache size: <?php echo realpath_cache_size(); ?>/<?php echo ini_get('realpath_cache_size'); ?> -->
in your htdocs/core/templates/layout.user.php preferably early in the document, after <!DOCTYPE html> so you can always check by accessing the page source.
On my development machine I was able to increase the realpath_cache_size by setting it to 512k in the php.ini. It then showed the following stats: <!-- cache size: 22398/512k -->
On my production server I could not increase the value and it always showed 0. Since I am using open_basedir to jail php into a certain directory I obviously ran into a known bug: https://bugs.php.net/bug.php?id=52312
On another server I did not have access to the php.ini and failed to increase the value. Neither by setting php_value realpath_cache_size 1M in the apache site config, nor in the .htaccess could I change the value.
All environments use apache prefork.
After disabling open_basedir I now get <!-- cache size: 47250/512k --> for my production server. @dietmaroc let me know how the server is configured and if an apc cache is already used.
Customer states: We have taken several steps to fix this problem but in vain:
Step 1.
/opt/rh/php54/root/etc/php.ini:
; Determines the size of the realpath cache to be used by PHP. This value should ; http://php.net/realpath-cache-size realpath_cache_size = 10000k ; Duration of time, in seconds for which to cache realpath information for a given ; http://php.net/realpath-cache-ttl realpath_cache_ttl = 12000
Step 2.
We have set AllowOverride to None for the entire www document tree to prevent Apache looking to .htaccess files. To do this we have also moved the (standard) content of /var/www/html/owncloud/.htaccess into apache config file:
/etc/httpd/conf.d/owncloud.conf :
<Directory /var/www/html/owncloud> AllowOverride None #was All
copied from .htaccess file of owncloud
Step 3:
APC is enabled, opcache is enabled, cache size and hit rate look good, apc.stat=0
For the test in question, the apache/prefork with 8 running httpd processes and MaxRequestsPerChild=4000 should be sufficient to keep the realpath cache usable between the requests.
@dietmaroc Can you please elaborate on why step 2 is necessary? I see no reason for doing this. THX
@dietmaroc could you verify the realpath_cache setting works as expected. I described a simple check earlier in https://github.com/owncloud/core/issues/6710#issuecomment-32032343?
Open since more than one year, I guess this is not relevant anymore. Closing, feel fee to reopen though.