core icon indicating copy to clipboard operation
core copied to clipboard

realpath_cache for owncloud code base not working

Open dietmaroc opened this issue 12 years ago • 7 comments

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

  1. have 20 files in the top-level directory
  2. sync them to an empty directory
  3. 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

dietmaroc avatar Jan 10 '14 12:01 dietmaroc

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.

DeepDiver1975 avatar Jan 10 '14 13:01 DeepDiver1975

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.

butonic avatar Jan 10 '14 14:01 butonic

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.

butonic avatar Jan 10 '14 15:01 butonic

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

SetEnvIfNoCase ^Authorization$ "(.+)" XAUTHORIZATION=$1 RequestHeader set XAuthorization %{XAUTHORIZATION}e env=XAUTHORIZATION ErrorDocument 403 /owncloud/core/templates/403.php ErrorDocument 404 /owncloud/core/templates/404.php php_value upload_max_filesize 512M php_value post_max_size 512M php_value memory_limit 512M SetEnv htaccessWorking true RewriteEngine on RewriteRule .\* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteRule ^.well-known/host-meta /public.php?service=host-meta [QSA,L] RewriteRule ^.well-known/carddav /remote.php/carddav/ [R] RewriteRule ^.well-known/caldav /remote.php/caldav/ [R] RewriteRule ^apps/([^/]_)/(._.(css|php))$ index.php?app=$1&getfile=$2 [QSA,L] RewriteRule ^remote/(.*) remote.php [QSA,L] AddType image/svg+xml svg svgz AddEncoding gzip svgz DirectoryIndex index.php index.html AddDefaultCharset utf-8 Options -Indexes

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 avatar Jan 15 '14 13:01 dietmaroc

@dietmaroc Can you please elaborate on why step 2 is necessary? I see no reason for doing this. THX

DeepDiver1975 avatar Jan 15 '14 13:01 DeepDiver1975

@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?

butonic avatar Jan 15 '14 15:01 butonic

Open since more than one year, I guess this is not relevant anymore. Closing, feel fee to reopen though.

LukasReschke avatar Feb 28 '15 23:02 LukasReschke