Here are some tips to increase XWiki's performance.
If you need high availability or if the load on your XWiki instance is too high you canto spread the load.
By default XWiki use an embedded instance of Solr for easy of use but if you find yourself struggling with very slow search you should probably give external Solr instance a try. You can use debug=true in the URL of the search to check how long is taken in Solr itself to know if improving Solr speeed would really change anything (the issue might come from the UI on XWiki side too).
Slow random number generation on UNIX
The library used for random number generation in Oracle's JVM relies on /dev/random by default for UNIX platforms.
Although /dev/random is more secure, it's possible to use /dev/urandom if the default JVM configuration instead.
To determine if your operating system exhibits this behavior, try displaying a portion of the file from a shell prompt:
If the command returns immediately, you can use /dev/random as the default generator for Oracle's JVM. If the command does not return immediately, use these steps to configure the JVM to use /dev/urandom:
- Open the $JAVA_HOME/jre/lib/security/java.security file in a text editor.
- Change the line:
- Save your change and exit the text editor.
Gzip compression and caching of static pages
We're working on making these features part of the XWiki core (see). 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:
- (note that this depends on 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
Alternatively you can run the following commands as root (sudo)
and configure your different modules as described below:
Mod Deflate Configuration
# Insert filter
# 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 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
On debian apache2 the config file for deflate is located under /etc/apache2/mods-enabled/deflate.conf
Mod Expire Configuration
ExpiresDefault "access plus 1 day"
ExpiresDefault "access plus 1 day"
Mod Proxy AJP Configuration
Allow from all
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.
If you use Tomcat(7) you need to enable the ajp connector in the /etc/tomcat7/server.xml. Comment out the following line with adding <!-- -->. Maybe give a comment why you did it.
<Connector port="8080" protocol="HTTP/1.1"
Uncomment the following line by removing the <!-- --> and add URIEncoding="UTF-8" to it.Maybe give a comment too.
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" URIEncoding="UTF-8"/>
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. Here are some good default values:
- For Java 8 (i.e. XWiki >= 8.1). Notice that there's no permgen anymore in Java 8:
- Small and medium installs: A minimum of 1024MB (-Xmx1024m)
- Large installs: 2048MB or beyond (-Xmx2048m).
- For Java 7 (i.e. XWiki < 8.1)
- Small installs: A minimum of 512MB of heap memory and 196MB of permGen (-Xmx512m -XX:MaxPermSize=196m)
- Medium installs: 1024MB for the heap and 196MB of permGen (-Xmx1024m -XX:MaxPermSize=196m)
- Large installs: 2048MB (or beyond) for the heap and 196MB of permGen (-Xmx2048m -XX:MaxPermSize=196m).
For your information here are the values used for the xwiki.org site:
Make sure you've set. This is especially important when you start having lots of documents.
Large number of users
When you have large number of users it's recommended to turn on implicit All Group, i.e. to consider that all users are members of XWiki.XWikiAllGroup by default in the configuration. This is achieved by editing the xwiki.cfg file and setting:
Then you should remove all the XObjects from the XWikiAllGroup page but you should keep the page since otherwise you won't be able to set permissions for this group. This will prevent XWiki from having to load all that page's XObjects representing the users (thousands of them if you have thousands of users).
Also make sure that the XWikiAllGroup is listed in the xwiki.users.initialGroups property (it's there by default if you haven't touched that property):
#-# document names.
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).
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 the 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:
# It could be also usefull to block certain spaces from crawling,
# especially if this spaces doesn't provide new content
# on the other hand you would like to have your recent (public) changes included
For Tomcat6 the placement of the robots.txt file should be within the $TOMCAT/webapps/ROOT folder and should have permission 644 applied.
In order to test if the robots.txt file is either accessable or working as desired use this .
The statistics module is off by default since it's quite database intensive. If you don't need it you should turn it off.
You can tune the Document cache in the xwiki.cfg configuration file. The value depends on how much memory you have. The higher the better. A good reasonable value is 1000.
It's possible to perform selective content caching by using the.
LESS CSS Performances
is a preprocessor used to generate CSS files for skins and skin extensions. See the of the LESS module documentation to learn more about how to optimize its cache for performances, and to set the appropriate number of simultaneous compilations your server can handle.
Some pages are complex to render (they may aggregate outside data for example or do complex and slow queries). For theses pages you can use rendering cache.
Pages can be cached (i.e. their rendered content cached) to speed up displaying. The configuration is done in xwiki.properties with the following configuration options:
#-# Indicate if the rendering cache is enabled.
#-# Default value is false.
#-# [Since 2.4M1]
#-# A list of Java regex patterns matching full documents reference.
#-# [Since 2.4M1]
#-# The time (in seconds) after which data should be removed from the cache when not used.
#-# Default value is 300 (5 min).
#-# [Since 2.4M1]
#-# The size of the rendering cache. Not that it's not the number of cached documents but the number of cached results.
#-# (For a single document several cache entries are created, because each action, language and request query string
#-# produces a unique rendering result)
#-# Default value is 100.
You can force a page to refresh using refresh=1 in the URL.
Since 6.2 it's also possible to programmatically refresh any document cache using com.xpn.xwiki.internal.cache.rendering.RenderingCache component:
private RenderingCache renderingCache;
renderingCache.flushCache(new DocumentReference("xwiki", "MySpace", "MyCachedDocument"));
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.
Set up NginX
If you experience on your wiki, you could try using NginX.
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 check.
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:
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:
In some cases you may not want 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.
Disable LDAP sub groups search
By default when loading a LDAP group, each member is searched and loaded to figure out if it's a group or not (and then load the sub group members, etc). Since 7.2 If you know there is not sub group in your LDAP groups you can disable it and speed up quite a lot big groups handling using xwiki.authentication.ldap.group_sync_resolve_subgroups property in xwiki.cfg configuration file.
Since 7.1 it's possible to directly get a tree of time spent in each step of the request by using.
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:
1.0 rendering cache using velocity in document content itself
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:
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.
Wiki syntax features for XWiki Syntax 1.0
If you're using XWiki Syntax 1.0 and if you don't plan to use all of the markup 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.
Now this will have no effect if you're using another syntax, like XWiki Syntax 2.x.