Performance
Here are some tips to increase XWiki's performance.
Gzip compression and caching of static pages
We're working on making these features part of the XWiki core (see XWIKI-2022). While waiting for this to be natively implemented, the recommended solution is to set up an Apache Web Server in front of your servlet container and install/configure the following modules:
- mod-deflate
- mod-expire
- mod-proxy-ajp (note that this depends on mod-proxy that you also need to install)
Modify your Apache configuration file to load the different modules:
LoadModule deflate_module /usr/lib/apache2/modules/mod_deflate.so
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
# Depends: proxy
LoadModule proxy_ajp_module /usr/lib/apache2/modules/mod_proxy_ajp.so
And configure your different modules as described below.
Mod Deflate Configuration
<Location />
# Insert filter
SetOutputFilter DEFLATE
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
# BrowserMatch bMSIE !no-gzip !gzip-only-text/html
# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won't work. You can use the following
# workaround to get the desired effect:
BrowserMatch bMSI[E] !no-gzip !gzip-only-text/html
# Don't compress images
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
#Header append Vary User-Agent env=!dont-vary
</Location>
Mod Expire Configuration
<Location /xwiki/skins/>
ExpiresActive on
ExpiresDefault "access plus 1 day"
</Location>
<Location /xwiki/bin/skin/>
ExpiresActive on
ExpiresDefault "access plus 1 day"
</Location>
Mod Proxy AJP Configuration
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPreserveHost On
ProxyPass /xwiki ajp://192.168.1.181:8009/xwiki
where ajp://192.168.1.181:8009/xwiki is the internal address of your Servlet container where XWiki is running.
Memory
You need to configure your Servlet container so that XWiki has enough memory. You'll need to tune the value to your need. You should check the logs and see if there are any out of memory errors. A good default value is 384MB (-Xmx384m).
Here are the values used for xwiki.org's web site:
Database Indexes
Make sure you've set Database indexes. This is especially important when you start having lots of documents.
Panels
Some Panels take more resources than others. For example the Navigation panel should NOT be used for wikis with a lot of documents since it displays all documents in the wiki. In the future that Panel should be improved for performance but that's not the case right now. Originally this Panel was only meant as a starting point. A better approach is to use a Quick Links Panel as we've now set up in the default XWiki Enterprise wiki version 1.1 (we've removed the default usage of the Navigation Panel in that version).
Robots.txt
If your wiki is open on the Internet, it'll be crawled by search robots (like GoogleBot, etc). They will call all the URLs and especially ones that are resource hungry like exports (PDF/RTF). You need to protect against this. To do so configure a robots.txt file like this one and put it in your webserver configuration:
Disallow: /xwiki/bin/xmlrpc/
Disallow: /xwiki/bin/pdf/
Disallow: /xwiki/bin/edit/
Disallow: /xwiki/bin/inline/
Disallow: /xwiki/bin/preview/
Disallow: /xwiki/bin/save/
Disallow: /xwiki/bin/cancel/
Disallow: /xwiki/bin/delete/
Disallow: /xwiki/bin/register/
Disallow: /xwiki/bin/propupdate/
Disallow: /xwiki/bin/propadd/
Disallow: /xwiki/bin/propdelete/
Disallow: /xwiki/bin/commentadd/
Disallow: /xwiki/bin/objectremove/
Disallow: /xwiki/bin/attach/
Disallow: /xwiki/bin/upload/
Disallow: /xwiki/bin/download/
Disallow: /xwiki/bin/dot/
Disallow: /xwiki/bin/delattachment/
Disallow: /xwiki/bin/skin/
Disallow: /xwiki/bin/login/
Disallow: /xwiki/bin/loginerror/
Disallow: /xwiki/bin/logout/
Disallow: /xwiki/bin/status/
Disallow: /xwiki/bin/lifeblog/
Disallow: /xwiki/bin/viewrev/
Disallow: /xwiki/bin/downloadrev/
Disallow: /xwiki/bin/viewattachrev/
Disallow: /xwiki/bin/export/
Statistics
The statistics module is off by default since it's quite Database intensive. If you don't need it you should turn it off.
Monitoring
More a developer-oriented feature, XWiki can monitor its own code, reporting the time spent for each sub-component activated during a request. While the monitoring code isn't time consuming, it increases the memory consumption a bit, and the create/start/stop/log/destroy calls are spread all around the code, so you will save a lot of method calls by disabling this. You can do that by setting the following line in xwiki.cfg:
Cache sizes
Tune the document cache in xwiki.cfg. The value depends on how much memory you have. The higher the better. A good reasonable value is 1000.
Rendering cache
Some pages are complex to render (they may aggregate outside data for example or do complex and slow queries). For these pages you can add the following to their content to cache them after they are rendered. Note that the document is refreshed whenever the content of the document changes, and the cache takes into account the URL, so it is pretty safe to add a long cache duration for all documents that don't contain scripts gathering data from the wiki. For example to cache the rendered content for 60 seconds you would add:
Since 1.5M2, you can set the default rendering cache duration for all pages in xwiki.cfg:
xwiki.rendering.defaultCacheDuration=3600
Setting the default cache duration to a large value, and manually disabling the cache in dynamic pages would really speed up the wiki, since the rendering is one of the most time consuming processes.
Merge the CSS files
In order to reduce the number of requests and files that are downloaded from the browser or client, it could help to merge all XWiki CSS files into a single one. See the Merge CSS Snippet
Set up NginX
If you experience heavy loads on your wiki, you could try using NginX.
NginX is used to fetch static content: images, javascript, styles, etc.
Unlike Apache, which instantiates a new process per every static file, NginX uses the same process to fetch all the static data, and thus gives you extra perfomance "for free".
For more info on setting up NginX look here
Backlinks
While a pretty neat feature, keeping track of the backlinks has a medium impact on the document saving time and a minor impact on the document loading time. If you feel that your wiki does not need backlinks, you can safely disable them with the following line in xwiki.cfg:
Versioning
One of the key features of any wiki system, versioning greatly affects the database size and the document update time. If you are sure your wiki does not need to keep track of all the changes and you will never need to revert documents to a previous version, then you can add the following line in xwiki.cfg
Custom Mapping
In some cases you may want not to rely on XWiki's generic database schema for storing XClass data and instead you'd like to provide your own optimized table. For these use cases you can use Custom Mapping.
Wiki syntax features for XWiki Syntax 1.0
If you don't plan to use all of the wiki features, like the strikethrough filter, the automatic http links filter, the SVG, Laszlo or style macros, you can disable them in xwiki-core-*.jar/META-INF/services/com.xpn.xwiki.render.*. The wiki rendering is the most costly operation in the rendering process, so any disabled feature counts.