Performance Tips¶
The performance of ownCloud, like any LAMP application, is dependent on all components of the stack. Maximizing performance can be achieved by optimizing the operations and interactions of the underlying network, hardware, operating systems, webservers, databases, and storage.
This guide cannot cover all possible configurations and will instead cover tips that are specific to ownCloud or give the greatest benefit.
SSL / Encryption App¶
SSL (HTTPS) and file encryption/decryption can be offloaded to a processor’s AES-NI extension. This can both speed up these operations while lowering processing overhead. This requires a processor with the AES-NI instruction set.
Here are some examples how to check if your CPU / environment supports the AES-NI extension:
- For each CPU core present:
grep flags /proc/cpuinfo
or as a summary for all cores:grep -m 1 ^flags /proc/cpuinfo
If the result contains anyaes
, the extension is present. - On Windows you can run
coreinfo
from Sysinternalswhich gives you details of the processor and extensions present.Note: you may have to run the command shell as administrator to get an output. - Search eg. on the Intel web if the processor used supports the extensionYou may set a filter by
"AES New Instructions"
to get a reduced result set. - For versions of openssl >= 1.0.1, AES-NI does not work via an engine and will not show up in the
openssl engine
command. It is active by default on the supported hardware.You can check the openssl version viaopenssl version -a
- If your processor supports AES-NI but it does not show up eg via grep or coreinfo, it is maybe disabled in the BIOS.
- If your environment runs virtualized, check the virtualization vendor for support.
OPcache Extension¶
OPcache improves PHP performance by storing precompiled script bytecode in shared memory, thereby removing the need for PHP to load and parse scripts on each request. This extension is bundled with PHP 5.5.0 and later, and is available in PECL for PHP versions 5.2, 5.3, and 5.4.
Object Caching¶
ownCloud is written to take advantage of object caching. Object caching can be done locally with the APCu extension, or for distributed PHP environments using Memcached. Memcached servers must be specified in the “memcached_servers” array in ownCloud’s config file.
Enable the SPDY protocol¶
Your webserver can be configured to use the SPDY protocol which could improve the overall performance of ownCloud. Please have a look at the documentation of your webservers module for more infos:
Note
If you want to enable SPDY for Apache please note the Known Issues of this module to avoid problems after enabling it.
Serving static files via web server¶
See the section Serving Static Files for Better Performance for a description and the benefits.
Using cron to perform background jobs¶
See the section Defining Background Jobs for a description and the benefits.
Using MySQL instead of SQLite¶
MySQL or MariaDB should be preferred because of the performance limitations of SQLite with highly concurrent applications, like ownCloud.
On large instances you could consider running MySQLTuner to optimize the database.
See the section Database Configuration how to configure ownCloud for MySQL or MariaDB. If your installation is already running on SQLite then it is possible to convert to MySQL or MariaDB using the steps provided in Converting From SQLite to MySQL, MariaDB, or PostgreSQL.
Improve slow performance with MySQL on Windows¶
On Windows hosts running MySQL on the same system changing the parameter dbhost
in your config/config.php
from localhost
to 127.0.0.1
could improve the page loading time.
See also this forum thread.
Nginx: caching ownCloud gallery thumbnails with fastcgi_cache_purge¶
Nginx module check¶
nginx cache purge
module compiled in.nginx -V 2>&1 | grep ngx_cache_purge -o
ngx_cache_purge
, you can continue with the configuration, else you need to manually compile Nginx with the module needed.Compile Nginx with the nginx-cache-purge
module¶
- Preparation
cd /opt
wget http://nginx.org/keys/nginx_signing.key
sudo apt-key add nginx_signing.key
sudo vi /etc/apt/sources.list.d/nginx.list
Add following lines (in case, replace{trusty}
by your distribution name):deb http://nginx.org/packages/mainline/ubuntu/ trusty nginx
deb -src http://nginx.org/packages/mainline/ubuntu/ trusty nginx
Then do asudo apt-get update
Note:If you’re not overly cautious and wish to install the latest and greatest Nginx packages and features, you may have to install Nginx from its mainline repository.From the Nginx homepage: “In general, you should deploy Nginx from its mainline branch at all times.”If you would like to use standard Nginx from the latest mainline branch but without compiling in any additional modules, just runsudo apt-get install nginx
. - Download the Nginx source from the ppa repository
cd /opt
sudo apt-get build-dep nginx
sudo apt-get source nginx
- Download module(s) to be compiled in and configure compiler arguments
ls -la
Please replace{release}
with the release downloadedcd /opt/nginx-{release}/debian
If folder “modules” is not present, do:sudo mkdir modules
cd modules
sudo git clone https://github.com/FRiCKLE/ngx_cache_purge.git
sudo vi /opt/nginx-{release}/debian/rules
If not present, add the following line at the top under#export DH_VERBOSE=1
:MODULESDIR = $(CURDIR)/debian/modules
And the end of every./configure
command add:--add-module=$(MODULESDIR)/ngx_cache_purge
Don’t forget to escape preceeding lines with a backslash\
.The parameters may now look :$(WITH_SPDY) \
--with-cc-opt="$(CFLAGS)" \
--with-ld-opt="$(LDFLAGS)" \
--with-ipv6 \
--add-module=$(MODULESDIR)/ngx_cache_purge
- Compile and install Nginx
cd /opt/nginx-{release}
sudo dpkg-buildpackage -uc -b
ls -la /opt
sudo dpkg --install /opt/nginx_{release}~{distribution}_amd64.deb
- Check if the compilation and installation of the
ngx_cache_purge
module was successfulnginx -V 2>&1 | grep ngx_cache_purge -o
It should show now:ngx_cache_purge
Show Nginx version including all features compiled and installed:nginx -V 2>&1 | sed s/" --"/"\n\t--"/g
- Mark Nginx to be blocked from further updates via
apt-get
sudo dpkg --get-selections | grep nginx
For eyery nginx component listed do a:sudo apt-mark hold <component>
- Regular checks for nginx updatesDo a regular visit on the Nginx news page and proceed in case of updates with item 2 to 5
Configure Nginx with the nginx-cache-purge
module¶
- PreparationCreate a directory where Nginx will save the cached thumbnails. Use any path that fits to your environment. Replace
{path}
with the path used, example path below:sudo mkdir -p /usr/local/tmp/cache
- Configuration
sudo vi /etc/nginx/sites-enabled/{your-ownCloud-nginx-config-file}
Note: thekeys_zone
/fastcgi_cache
name and the{path}
must be unique to each instance of ownCloud serverd with Nginx !Add at the beginning, but outside theserver{}
block:fastcgi_cache_path {path} levels=1:2 keys_zone=OWNCLOUD:100m inactive=60m;
Add inside theserver{}
block, as an example of a configuration:set $skip_cache 1;
# POST requests and urls with a query string should always go to PHP
if ($request_uri ~* "thumbnail.php") {
set $skip_cache 0;
}
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout invalid_header http_500;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
location ~ \.php(?:$|/) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param HTTPS on;
fastcgi_pass php-handler;
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
fastcgi_cache OWNCLOUD;
fastcgi_cache_valid 60m;
}
Note regarding thefastcgi_pass
parameter:Use whatever fits your configuration. In the example above, aupstream
was defined in an Nginx global configuration file.This then can look like:upstream php-handler {
server 127.0.0.1:9000;
# or
#server unix:/var/run/php5-fpm.sock;
}
- Test the configuration
sudo service nginx restart
- Open your browser and clear your cache.
- Logon to your ownCloud instance, open the gallery app, move thru your foldersand watch while the thumbs are generated for the first time.
- You may also watch with eg.
htop
your system load while the thumbnails are processed. - Goto another app or logout and relogon.
- Open the gallery app again and browse to the folders you accessed before.Your thumbnails should appear more or less immediately.
htop
will not show up additional load while processing, compared to the high load before.