Server Tuning & Performance Tips

There are a number of options to tune the ownCloud installation and enable a higher level of performance. This chapter gives a few hands-on tips on configuring your database, and LAMP stack to improve performance. This chapter is community-maintained and unsupported; test these tips carefully before deploying them on production servers.

If you wish to add tips to this page, please put them in the relevant section. If there isn’t an appropriate section then start a new one.

PHP Version and Information

You will need to know your PHP version and configurations. To do this, create a plain-text file named phpinfo.php and place it in your Web root, for example /var/www/html/phpinfo.php. (Your Web root may be in a different location; your Linux distribution documentation will tell you where.) This file contains just this line:

<?php phpinfo(); ?>

Open this file in a Web browser by pointing your browser to localhost/phpinfo.php:

../_images/phpinfo.png

Your PHP version is at the top, and the rest of the page contains abundant system information such as active modules, active .ini files, and much more. When you are finished reviewing your information you must delete phpinfo.php, or move it outside of your Web directory, because it is a security risk to expose such sensitive data.

ownCloud Server Tuning

Serving static files via web server

See Serving Static Files for Better Performance for a description and the benefits.

Using cron to perform background jobs

See Defining Background Jobs for a description and the benefits.

Enable JavaScript and CSS Asset Management

See JavaScript and CSS Asset Management for a description and the benefits.

Webserver Tips

PHP safe mode

PHP safe mode has to be turned off. It is deprecated and has been removed in newer PHP versions. Verify its status in phpinfo_, and look for safe_mode on/off. If it is on, then add this line to php.ini to turn it off:

safe_mode = Off

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 information:

Note

If you want to enable SPDY for Apache please note the Known Issues of this module to avoid problems after enabling it.

Apache Tuning

Maximum number of Apache processes

An Apache process uses around 12MB of RAM. Apache should be configured so that the maximum number of HTTPD processes times 12MB is lower than the amount of RAM. Otherwise the system begins to swap and the performance goes down.

KeepAlive should be configured with sensible defaults

KeepAlive On
KeepAliveTimeout 2
MaxKeepAliveRequests 10

mod_gzip

mod_gzip should be used because it speeds up the transfer of data and helps to free server memory, and HTTP connections are closed faster.

MPM

Apache prefork has to be used. Don’t use threaded mpm with mod_php because PHP is currently not thread safe.

Hostname Lookups

# cat /etc/httpd/conf/httpd.conf
...
HostnameLookups off

Log files

Log files should be switched off for maximum performance.

Comment out the CustomLog directive. Keep ErrorLog to be able to track down errors.

MaxKeepAliveRequests 4096

<IfModule prefork.c>
        StartServers 100
        MinSpareServers 100
        MaxSpareServers 2000
        ServerLimit 6000
        MaxClients 6000
        MaxRequestsPerChild 4000
</IfModule>

<Directory "/var/www/html">
        Options Indexes SymLinksIfOwnerMatch AllowOverride All
</Directory>

Database Best Practice

Currently ownCloud supports the following relational database management systems:

  • MySQL
  • MariaDB
  • PostgreSQL
  • SQLite
  • Oracle

SQLite is not supported in the Enterprise edition, and is not recommended except for systems with very light workloads, and for testing ownCloud.

We are using the doctrine database abstraction layer and schema evolution with a MDB2 Schema based table description in XML.

Using MariaDB/MySQL instead of SQLite

MySQL or MariaDB are 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 for 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 Database Type.

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.

Other performance improvements

Mysql: compare https://tools.percona.com/wizard to your current settings MariaDB: https://mariadb.com/kb/en/optimization-and-tuning/

Postgresql

Alternative to MariaDB/MySQL. Used in production by a few core developers.

Requires at least Postgresql 9.0

Oracle Database

Usage scenario: Existing enterprise installations. Only core apps are supported and tested. Not recommended because it involves compiling the oci8

Other performance improvements

http://de.slideshare.net/cjorcl/best-practices-php-and-the-oracle-database and ask your DBA.

Problems

When ORA-56600 occurs (Oracle Bug 8467564) set this php.ini setting: oci8.statement_cache_size=1000, see oracle forum discussion

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 any aes, the extension is present.
  • Search eg. on the Intel web if the processor used supports the extension Intel Processor Feature Filter You 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 via openssl 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.