Wiki source code of Performance

Version 126.1 by Thomas Mortagne on 2024/09/04

Hide last authors
HDirkSchmitt 22.1 1 {{box cssClass="floatinginfobox" title="**Contents**"}}
2 {{toc/}}
3 {{/box}}
Silvia Macovei 20.1 4
Niels Mayer 17.1 5 Here are some tips to increase XWiki's performance.
Vincent Massol 10.1 6
Vincent Massol 49.1 7 = Clustering =
8
Vincent Massol 89.1 9 If you need high availability or if the load on your XWiki instance is too high you can [[configure XWiki in a cluster>>Documentation.AdminGuide.Clustering.WebHome]] to spread the load.
Vincent Massol 49.1 10
Vincent Massol 48.1 11 = Standalone Solr =
12
Patrik Mattsson 110.2 13 By default XWiki use an embedded instance of Solr for ease of use, but if you struggle with very slow searches, you should try a external Solr instance.
14 You can use ##debug=true## in the URL of the search to see how much time is spent inside Solr to verify if Solr is taking a long time, or the issue is somewhere else, for example the XWiki UI.
Guillaume Delhumeau 50.1 15
Thomas Mortagne 65.1 16 See [[Performance Guide in Solr module documentation>>extensions:Extension.Solr Search API#HPerformances]].
Thomas Mortagne 64.1 17
Thomas Mortagne 42.1 18 = Slow random number generation on UNIX =
19
Thomas Mortagne 126.1 20 Since Java 8 the default random generator used by the JVM on UNIX systems is generally ##/dev/urandom## which should always be fast, but just in case you are in a setup in which it's not the case, this section can be interersting.
21
Thomas Mortagne 67.1 22 The library used for random number generation in Oracle's JVM relies on ##/dev/random## by default for UNIX platforms.
Thomas Mortagne 42.1 23
Vincent Massol 48.3 24 Although ##/dev/random## is more secure, it's possible to use ##/dev/urandom## if the default JVM configuration instead.
Thomas Mortagne 42.1 25
26 To determine if your operating system exhibits this behavior, try displaying a portion of the file from a shell prompt:
27
Thomas Mortagne 45.1 28 {{code language="bash"}}
Thomas Mortagne 42.1 29 head -n 1 /dev/random
Thomas Mortagne 45.1 30 {{/code}}
Thomas Mortagne 42.1 31
Thomas Mortagne 79.1 32 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 on of the following solutions to use ##/dev/urandom##:
Thomas Mortagne 42.1 33
Thomas Mortagne 79.1 34 == JVM setup ==
35
Thomas Mortagne 44.1 36 1. Open the ##$JAVA_HOME/jre/lib/security/java.security## file in a text editor.
37 1. Change the line:
Guillaume Delhumeau 50.1 38 {{code language="properties"}} securerandom.source=file:/dev/random{{/code}}
Thomas Mortagne 42.1 39 to read:
Guillaume Delhumeau 50.1 40 {{code language="properties"}} securerandom.source=file:/dev/urandom{{/code}}
Thomas Mortagne 44.1 41 1. Save your change and exit the text editor.
Thomas Mortagne 42.1 42
Thomas Mortagne 79.1 43 == Command line parameter ==
44
Thomas Mortagne 109.1 45 The same effect can be obtained using ##-Djava.security.egd=file:/dev/./urandom## in the Java command line (usually in the application server configuration).
Thomas Mortagne 79.1 46
Silvia Macovei 20.2 47 = Gzip compression and caching of static pages =
Vincent Massol 14.1 48
Thomas Mortagne 92.1 49 HTTP compression is a capability that can be built into web servers and web clients to improve transfer speed and bandwidth utilization. HTTP data is compressed before it is sent from the server: compliant browsers will announce what methods are supported to the server before downloading the correct format; browsers that do not support compliant compression method will download uncompressed data.
Vincent Massol 14.1 50
Thomas Mortagne 94.1 51 Many application servers (Tomcat, etc.) and HTTP proxies (Apache HTTPd, Nginx, etc.) support it.
Thomas Mortagne 92.1 52
Thomas Mortagne 93.1 53 == In Apache HTTP Server ==
Thomas Mortagne 92.1 54
55 The recommended solution is to set up an Apache Web Server in front of your servlet container and install/configure the following modules:
56
Silvia Macovei 20.1 57 * [[mod-deflate>>http://httpd.apache.org/docs/2.0/mod/mod_deflate.html]]
Pascal Bastien 81.1 58 * [[mod-expires>>http://httpd.apache.org/docs/2.0/mod/mod_expires.html]]
Silvia Macovei 20.1 59 * [[mod-proxy-ajp>>http://httpd.apache.org/docs/2.2/mod/mod_proxy_ajp.html]] (note that this depends on [[mod-proxy>>http://httpd.apache.org/docs/2.2/mod/mod_proxy.html]] that you also need to install)
60
Vincent Massol 14.1 61 Modify your Apache configuration file to load the different modules:
62
Silvia Macovei 20.1 63 {{code language="none"}}
Vincent Massol 14.1 64 LoadModule expires_module /usr/lib/apache2/modules/mod_expires.so
65 LoadModule deflate_module /usr/lib/apache2/modules/mod_deflate.so
66 LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
67 # Depends: proxy
68 LoadModule proxy_ajp_module /usr/lib/apache2/modules/mod_proxy_ajp.so
Silvia Macovei 20.1 69 {{/code}}
Vincent Massol 14.1 70
KaiSen 37.1 71 //Alternatively you can run the following commands as root (sudo)//
72
73 {{code language="bash"}}
74 a2enmod deflate
75 a2enmod proxy_ajp
76 a2enmod expires
77 {{/code}}
78
Manuel Smeria 32.2 79 and configure your different modules as described below:
Vincent Massol 14.1 80
Thomas Mortagne 92.1 81 === Mod Deflate Configuration ===
Vincent Massol 14.1 82
Silvia Macovei 20.1 83 {{code language="none"}}
Vincent Massol 14.1 84 vwwwpro-1:~# cat /etc/apache2/conf.d/deflate
Eduard Moraru 118.1 85 <Location ></Location>
Vincent Massol 14.1 86 # Insert filter
87 SetOutputFilter DEFLATE
88
89 # Netscape 4.x has some problems...
90 BrowserMatch ^Mozilla/4 gzip-only-text/html
91
92 # Netscape 4.06-4.08 have some more problems
Silvia Macovei 20.1 93 BrowserMatch ^Mozilla/4.0[678] no-gzip
Vincent Massol 14.1 94
95 # MSIE masquerades as Netscape, but it is fine
Silvia Macovei 20.1 96 # BrowserMatch bMSIE !no-gzip !gzip-only-text/html
Vincent Massol 14.1 97
98 # NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
99 # the above regex won't work. You can use the following
100 # workaround to get the desired effect:
Silvia Macovei 20.1 101 BrowserMatch bMSI[E] !no-gzip !gzip-only-text/html
Vincent Massol 14.1 102
103 # Don't compress images
Silvia Macovei 20.1 104 SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary
Vincent Massol 14.1 105
106 # Make sure proxies don't deliver the wrong content
107 #Header append Vary User-Agent env=!dont-vary
108 </Location>
Silvia Macovei 20.1 109 {{/code}}
Vincent Massol 14.1 110
KaiSen 37.1 111 //On debian apache2 the config file for deflate is located under /etc/apache2/mods-enabled/deflate.conf//
112
Thomas Mortagne 92.1 113 === Mod Expire Configuration ===
Vincent Massol 14.1 114
Silvia Macovei 20.1 115 {{code language="none"}}
Vincent Massol 14.1 116 vwwwpro-1:~# cat /etc/apache2/conf.d/expires
Eduard Moraru 118.1 117 <Location /xwiki/skins></Location>
Vincent Massol 14.1 118 ExpiresActive on
119 ExpiresDefault "access plus 1 day"
120 </Location>
121
Eduard Moraru 118.1 122 <Location /xwiki/bin/skin></Location>
Vincent Massol 14.1 123 ExpiresActive on
124 ExpiresDefault "access plus 1 day"
125 </Location>
Silvia Macovei 20.1 126 {{/code}}
Vincent Massol 14.1 127
Thomas Mortagne 92.1 128 === Mod Proxy AJP Configuration ===
Vincent Massol 14.1 129
Silvia Macovei 20.1 130 {{code language="none"}}
131 ProxyRequests Off
Vincent Massol 14.1 132 <Proxy *>
133 Order deny,allow
134 Allow from all
135 </Proxy>
136 ProxyPreserveHost On
137 ProxyPass /xwiki ajp://192.168.1.181:8009/xwiki
Silvia Macovei 20.1 138 {{/code}}
Vincent Massol 14.1 139
Jan-Paul Kleijn 119.15 140 where {{code}}ajp://192.168.1.181:8009/xwiki{{/code}} is the internal address of your Servlet container where XWiki is running.
Vincent Massol 14.1 141
Jan-Paul Kleijn 119.16 142 If you use Tomcat(9) you need to enable the ajp connector in the ##/etc/tomcat9/server.xml##. Comment out the following line with adding ##<!~-~- ~-~->##.
KaiSen 37.1 143
144 {{code}}
Jan-Paul Kleijn 119.16 145 <!-- Disable to use ajp connector instead
Jan-Paul Kleijn 119.17 146 <Connector port="8080"
147 protocol="HTTP/1.1"
KaiSen 37.1 148 connectionTimeout="20000"
149 URIEncoding="UTF-8"
Jan-Paul Kleijn 119.18 150 redirectPort="8443">
Jan-Paul Kleijn 119.17 151 </Connector>
Jan-Paul Kleijn 119.16 152 -->
KaiSen 37.1 153 {{/code}}
154
Jan-Paul Kleijn 119.13 155 Uncomment the following line by removing the ##<!~-~- ~-~->## and add {{code}}URIEncoding="UTF-8"{{/code}} to it.
Jan-Paul Kleijn 119.9 156
KaiSen 37.1 157 {{code}}
Jan-Paul Kleijn 119.21 158 <!-- Activate ajp connector for apache proxy_ajp -->
Jan-Paul Kleijn 119.17 159 <Connector port="8009"
160 protocol="AJP/1.3"
161 redirectPort="8443"
162 URIEncoding="UTF-8">
163 </Connector>
KaiSen 37.1 164 {{/code}}
165
Silvia Macovei 20.2 166 = Memory =
Vincent Massol 9.1 167
Jan-Paul Kleijn 119.26 168 You need to configure your Servlet container so that XWiki has enough memory. This is done in the ##/etc/default/tomcat9## configuration file (or ##/etc/default/tomcat8## for Tomcat 8, etc). You'll need to tune the value to suit your needs. For possible memory issues you can check the logs to see if there are any "out of memory" errors.
Marc Lijour 36.1 169
Jan-Paul Kleijn 119.25 170 Here are some good default values:
Jan-Paul Kleijn 119.27 171
Thomas Mortagne 112.1 172 * Small and medium installs: A minimum of 1024MB (##-Xmx1024m)##
Jan-Paul Kleijn 119.24 173 * Large installs: 2048MB or beyond (##-Xmx2048m)##
Vincent Massol 9.1 174
Vincent Massol 53.3 175 {{info}}
Vincent Massol 53.1 176 You should not increase the memory beyond what you need because increasing it means that there's more Objects in memory at any time and the automatic JVM Garbage Collector has to work harder to clean itself, which can results in performance degradation in XWiki (since a full GC will pause the application for a longer time).
Vincent Massol 53.3 177 {{/info}}
Vincent Massol 53.1 178
Vincent Massol 34.1 179 {{warning}}
Ecaterina Moraru (Valica) 88.5 180 If you use HSQLDB as the wiki database, be aware that the full content of the database is stored in memory and thus the memory requirements are higher. See [[HSQLDB installation page>>Documentation.AdminGuide.Installation.InstallationWAR.InstallationHSQL.WebHome]] for more details.
Vincent Massol 76.1 181 {{/warning}}
182
Vincent Massol 35.1 183 For your information here are the values used for the xwiki.org site:
184
185 {{code}}
Thomas Mortagne 125.1 186 CATALINA_OPTS="-server -Xms1080m -Xmx1600m -Dfile.encoding=utf-8 -Djava.awt.headless=true --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.util.concurrent=ALL-UNNAMED"
Vincent Massol 35.1 187 {{/code}}
188
Vincent Massol 105.1 189 = Sizing =
190
Vincent Massol 105.2 191 To give you an idea about what you need to run XWiki on, [[XWiki SAS>>https://xwiki.com]] has the following configuration for its cloud instances:
Vincent Massol 105.1 192
Vincent Massol 106.4 193 * 2GB of RAM (See [[XWiki memory needs>>#HMemory]]),
Vincent Massol 106.1 194 * 2 cores(((
195 {{code language="none"}}
196 AMD Opteron(tm) Processor 6386 SE
197 cpu MHz : 2800.000
198 cache size : 2048 KB
Vincent Massol 106.2 199 {{/code}}
Vincent Massol 106.1 200 )))
Vincent Massol 105.1 201 * 16GB disk size by default
202
Silvia Macovei 20.2 203 = Database Indexes =
Vincent Massol 1.1 204
Vincent Massol 90.1 205 Make sure you've set [[Database indexes>>Documentation.AdminGuide.Performances.Database Administration.WebHome]]. This is especially important when you start having lots of documents.
Vincent Massol 1.1 206
Vincent Massol 74.1 207 = Large number of users =
208
209 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:
210
211 {{code language="none"}}
212 xwiki.authentication.group.allgroupimplicit=1
213 {{/code}}
214
Vincent Massol 75.1 215 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).
Vincent Massol 74.1 216
Vincent Massol 75.2 217 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):
218
219 {{code language="none"}}
220 #-# List of groups that a new user should be added to by default after registering. Comma-separated list of group
221 #-# document names.
222 # xwiki.users.initialGroups=XWiki.XWikiAllGroup
223 {{/code}}
224
Silvia Macovei 20.2 225 = Robots.txt =
Vincent Massol 15.1 226
Vincent Massol 86.6 227 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 and put it in your webserver configuration.
Vincent Massol 15.1 228
Vincent Massol 85.1 229 Some example:
230
Silvia Macovei 20.1 231 {{code language="none"}}
Vincent Massol 15.1 232 User-agent: *
Vincent Massol 86.7 233 # Prevent bots from executing all actions except "view" since:
Vincent Massol 86.1 234 # 1) we don't want bots to execute stuff in the wiki!
Vincent Massol 86.2 235 # 2) we don't want bots to consume CPU and memory
Vincent Massol 86.7 236 # (for example to perform exports)
237 # Note: You may want to allow /download/ if you wish to have
238 # attachments indexed.
Eduard Moraru 111.1 239 # Note2: Using * instead of /bin/ to also match path-based
240 # subwikis like "/xwiki/wiki/wikialias/view/Space/Page"
241 Disallow: /xwiki/*/viewattachrev/
242 Disallow: /xwiki/*/viewrev/
243 Disallow: /xwiki/*/pdf/
244 Disallow: /xwiki/*/tex/
245 Disallow: /xwiki/*/edit/
246 Disallow: /xwiki/*/create/
247 Disallow: /xwiki/*/inline/
248 Disallow: /xwiki/*/preview/
249 Disallow: /xwiki/*/save/
250 Disallow: /xwiki/*/saveandcontinue/
251 Disallow: /xwiki/*/rollback/
252 Disallow: /xwiki/*/deleteversions/
253 Disallow: /xwiki/*/cancel/
254 Disallow: /xwiki/*/delete/
255 Disallow: /xwiki/*/deletespace/
256 Disallow: /xwiki/*/undelete/
257 Disallow: /xwiki/*/reset/
258 Disallow: /xwiki/*/register/
259 Disallow: /xwiki/*/propupdate/
260 Disallow: /xwiki/*/propadd/
261 Disallow: /xwiki/*/propdisable/
262 Disallow: /xwiki/*/propenable/
263 Disallow: /xwiki/*/propdelete/
264 Disallow: /xwiki/*/objectadd/
265 Disallow: /xwiki/*/commentadd/
266 Disallow: /xwiki/*/commentsave/
267 Disallow: /xwiki/*/objectsync/
268 Disallow: /xwiki/*/objectremove/
269 Disallow: /xwiki/*/attach/
270 Disallow: /xwiki/*/upload/
271 Disallow: /xwiki/*/download/
272 Disallow: /xwiki/*/temp/
273 Disallow: /xwiki/*/downloadrev/
274 Disallow: /xwiki/*/dot/
275 Disallow: /xwiki/*/svg/
276 Disallow: /xwiki/*/delattachment/
277 Disallow: /xwiki/*/skin/
278 Disallow: /xwiki/*/jsx/
279 Disallow: /xwiki/*/ssx/
280 Disallow: /xwiki/*/login/
281 Disallow: /xwiki/*/loginsubmit/
282 Disallow: /xwiki/*/loginerror/
283 Disallow: /xwiki/*/logout/
284 Disallow: /xwiki/*/charting/
285 Disallow: /xwiki/*/lock/
286 Disallow: /xwiki/*/redirect/
287 Disallow: /xwiki/*/admin/
288 Disallow: /xwiki/*/export/
289 Disallow: /xwiki/*/import/
290 Disallow: /xwiki/*/get/
291 Disallow: /xwiki/*/distribution/
292 Disallow: /xwiki/*/imagecaptcha/
293 Disallow: /xwiki/*/unknown/
Eduard Moraru 111.4 294 # Note: In addition, this matches both old /xwiki/bin/webjars/
295 # and new /xwiki/webjars paths.
Eduard Moraru 111.1 296 Disallow: /xwiki/*/webjars/
Eduard Moraru 111.4 297 # Don't index additional UI-related resources.
298 Disallow: /xwiki/resources/
Vincent Massol 86.2 299 # Don't index sandbox content since it's sample content
Eduard Moraru 111.1 300 Disallow: /xwiki/*/view/Sandbox/
Vincent Massol 86.2 301 # Don't index Admin space since it contains Admin stuff.
302 # Note that the Admin space is protected by permissions
303 # anyway but this acts as a safety net to not have private
304 # info leaked on the internet ;)
Eduard Moraru 111.1 305 Disallow: /xwiki/*/view/Admin/
Vincent Massol 86.2 306 # Don't index Stats data (just because it's not useful and
307 # those pages are a bit CPU intensive)
Eduard Moraru 111.1 308 Disallow: /xwiki/*/view/Stats/
Vincent Massol 86.2 309 # Don't index Panels data (because we don't want it
310 # indexed on the internet)
Eduard Moraru 111.1 311 Disallow: /xwiki/*/view/Panels/
312 # Don't index the search page.
313 Disallow: /xwiki/*/Main/Search
314 # Don't index the REST API.
315 Disallow: /xwiki/rest/
316 # These are just UI elements which can cause infinite loops in
317 # web crawlers. See https://jira.xwiki.org/browse/XWIKI-16915
318 Disallow: /xwiki/*?*xpage=*
Vincent Massol 86.1 319 {{/code}}
320
321 Other example:
322
323 {{code}}
324 [...]
Vincent Massol 85.1 325 # It could be also useful to block certain spaces from crawling,
HDirkSchmitt 22.1 326 # especially if this spaces doesn't provide new content
327 Disallow: /xwiki/bin/view/Main/
328 Disallow: /xwiki/bin/view/XWiki/
Vincent Massol 85.1 329 # On the other hand you would like to have your recent (public) changes included
HDirkSchmitt 22.1 330 Allow: /xwiki/bin/view/Main/Dashboard
Silvia Macovei 20.1 331 {{/code}}
Vincent Massol 15.1 332
Manuel Smeria 32.2 333 **Note:**
kayasaman 32.1 334
Manuel Smeria 32.2 335 For Tomcat6 the placement of the ##robots.txt## file should be within the //$TOMCAT/webapps/ROOT// folder and should have permission 644 applied.
kayasaman 32.1 336
337 {{code}}
338 -rw-r--r-- 1 root www 1478 Jan 8 15:52 robots.txt
339 {{/code}}
340
Eduard Moraru 115.1 341 == Indexing JS and CSS ==
kayasaman 32.1 342
Eduard Moraru 116.1 343 [[Google officially recommends>>https://developers.google.com/search/blog/2014/10/updating-our-technical-webmaster]] that you do not disallow crawling of the JS and CSS files which are now actually rendered by the crawler bot and used to better index your content. Also see this short [[video>>https://www.youtube.com/watch?v=B9BWbruCiDc]] on the topic.
Eduard Moraru 115.1 344
345 In this case, you might want to make sure to **remove** the following ##Disallow## entries from your robots.txt file:
346
Eduard Moraru 118.1 347 {{code language="none"}}
Eduard Moraru 115.1 348 Disallow: /xwiki/*/skin/
349 Disallow: /xwiki/*/jsx/
350 Disallow: /xwiki/*/ssx/
351 Disallow: /xwiki/*/webjars/
352 Disallow: /xwiki/*/resources/
353 {{/code}}
354
Eduard Moraru 116.1 355 == Indexing images ==
Eduard Moraru 115.1 356
Eduard Moraru 116.1 357 For images uploaded as attachments inside wiki pages, you should **add** the following ##Allow## entries for the ##/download/## action:
358
Eduard Moraru 118.1 359 {{code language="none"}}
Eduard Moraru 115.1 360 Allow: /xwiki/*/download/*.png$
361 Allow: /xwiki/*/download/*.jpg$
362 Allow: /xwiki/*/download/*.jpeg$
363 Allow: /xwiki/*/download/*.gif$
364 {{/code}}
365
366
367 In order to **test** if the ##robots.txt## file is either accessible or working as desired use this [[checker>>https://technicalseo.com/tools/robots-txt/]].
368
Silvia Macovei 20.2 369 = Statistics =
Vincent Massol 1.1 370
Silvia Macovei 20.1 371 {{info}}
372 This is no longer true starting with XE 1.4M2 since statistics are now put on a queue and written in a different thread in the database in one go, thus reducing the overhead to a maximum.
373 {{/info}}
Vincent Massol 15.1 374
Manuel Smeria 32.2 375 The statistics module is off by default since it's quite database intensive. If you don't need it you should turn it off.
Eduard Moraru 110.4 376 The current recommendation is to use the [[Matomo extension>>extensions:Extension.Piwiki Integration]] for statistics instead.
Vincent Massol 1.2 377
Vincent Massol 52.3 378 = Document Cache =
Vincent Massol 1.2 379
Vincent Massol 114.2 380 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 (but of course it's not very useful to allocate more than the total number of documents you have).
Vincent Massol 2.1 381
Silvia Macovei 20.1 382 {{code language="none"}}
kuchumovn 19.1 383 xwiki.store.cache.capacity=1000
Silvia Macovei 20.1 384 {{/code}}
Vincent Massol 8.1 385
Vincent Massol 25.1 386 = Cache Macro =
387
Vincent Massol 26.1 388 It's possible to perform selective content caching by using the [[Cache Macro>>extensions:Extension.Cache Macro]].
Vincent Massol 25.1 389
Guillaume Delhumeau 77.1 390 = LESS CSS Performances =
Guillaume Delhumeau 51.1 391
Guillaume Delhumeau 77.1 392 [[LESS>>extensions:Extension.LESS Module]] is a preprocessor used to generate CSS files for skins and skin extensions. See the [[Performances section>>extensions:Extension.LESS Module#HPerformances]] 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.
Guillaume Delhumeau 51.1 393
Silvia Macovei 20.2 394 = Rendering cache =
Vincent Massol 2.1 395
Vincent Massol 122.1 396 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 the rendering cache. When doing so, any change made to these pages won't be displayed to the user until the cache expires. Note that when a page is modified, the cache for the page is refreshed.
Thomas Mortagne 30.1 397
Vincent Massol 121.2 398 The configuration is done in ##xwiki.properties## with the following configuration options:
Vincent Massol 25.1 399
400 {{code language="none"}}
401 #-# [Since 2.4M1]
402 #-# Indicate if the rendering cache is enabled.
403 #-# Default value is false.
404 # core.renderingcache.enabled=true
405
406 #-# [Since 2.4M1]
407 #-# A list of Java regex patterns matching full documents reference.
408 # core.renderingcache.documents=wiki:Space\.Page
409 # core.renderingcache.documents=wiki:Space\..*
410
411 #-# [Since 2.4M1]
412 #-# The time (in seconds) after which data should be removed from the cache when not used.
413 #-# Default value is 300 (5 min).
414 # core.renderingcache.duration=300
415
416 #-# [Since 2.4M1]
417 #-# The size of the rendering cache. Not that it's not the number of cached documents but the number of cached results.
418 #-# (For a single document several cache entries are created, because each action, language and request query string
419 #-# produces a unique rendering result)
420 #-# Default value is 100.
421 # core.renderingcache.size=100
422 {{/code}}
423
Thomas Mortagne 31.1 424 You can force a page to refresh using ##refresh=1## in the URL.
Thomas Mortagne 30.1 425
Vincent Massol 121.3 426 It's also possible to programmatically refresh any document cache using ##com.xpn.xwiki.internal.cache.rendering.RenderingCache## component:
Thomas Mortagne 39.1 427
428 {{code language="java"}}
429 @Inject
430 private RenderingCache renderingCache;
431
432 ...
433
434 renderingCache.flushWholeCache();
435 renderingCache.flushCache(new DocumentReference("xwiki", "MySpace", "MyCachedDocument"));
436 {{/code}}
437
Silvia Macovei 20.2 438 = Merge the CSS files =
Vincent Massol 11.1 439
Eduard Moraru 110.5 440 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 Script>>snippets:Extension.Merge CSS]].
Vincent Massol 11.1 441
Silvia Macovei 20.2 442 = Set up NginX =
kuchumovn 19.2 443
Manuel Smeria 32.2 444 If you experience //__heavy loads__// on your wiki, you could try using NginX.
kuchumovn 19.3 445
Marc Lijour 36.1 446 NginX is used to fetch static content: images, javascript, styles, etc, but it can also be used as a reverse-proxy to pass requests down to the web container (e.g. Tomcat on port 8080).
kuchumovn 19.2 447
Manuel Smeria 32.2 448 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".
kuchumovn 19.2 449
Vincent Massol 91.1 450 For more info on setting up NginX check [[this guide>>Documentation.AdminGuide.Installation.NginX.WebHome]].
kuchumovn 19.2 451
Simon Urli 107.1 452 = Local resource access =
453
Vincent Massol 108.1 454 [[See URL API>>extensions:Extension.URL API#HResourcemodificationdate]].
Simon Urli 107.1 455
Silvia Macovei 20.2 456 = Backlinks =
Sergiu Dumitriu 4.1 457
Silvia Macovei 20.1 458 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##:
459
460 {{code language="none"}}
kuchumovn 19.1 461 xwiki.backlinks=0
Silvia Macovei 20.1 462 {{/code}}
Sergiu Dumitriu 5.1 463
Silvia Macovei 20.2 464 = Versioning =
Sergiu Dumitriu 5.1 465
Manuel Smeria 32.2 466 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##:
Silvia Macovei 20.1 467
468 {{code language="none"}}
kuchumovn 19.1 469 xwiki.store.versioning=0
Silvia Macovei 20.1 470 {{/code}}
Sergiu Dumitriu 6.1 471
Vincent Massol 21.1 472 = Custom Mapping =
Sergiu Dumitriu 6.1 473
Thomas Mortagne 120.1 474 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 [[Custom Mapping>>Documentation.DevGuide.CustomMapping]].
Vincent Massol 21.1 475
Thomas Mortagne 73.1 476 = LDAP =
477
478 == Disable LDAP sub groups search ==
479
Thomas Mortagne 114.1 480 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). If you know there is no 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.
Thomas Mortagne 73.1 481
Thomas Mortagne 56.1 482 = Performance tree =
483
Thomas Mortagne 57.1 484 Since 7.1 it's possible to directly get a tree of time spent in each step of the request by using [[debug mode>>dev:Community.Debugging#HDebugmode]].
Thomas Mortagne 68.1 485
Vincent Massol 98.2 486 = Navigation Tree =
Vincent Massol 98.1 487
488 The Navigation Panel and other navigation trees can have some small performance issues under very high volumes. Here ares some base measures we did on some developer laptops to give you some ideas of the performance you should expect:
489
490 Measure set 1:
491
Eduard Moraru 111.1 492 (% class="table-bordered" style="width:100%" %)
Vincent Massol 101.2 493 |=(% width="20%" %)DB|=(% width="10%" %)Levels|=(% width="10%" %)Spaces|=(% width="10%" %)Pages|=(% width="15%" %)Requests|=Time
Ecaterina Moraru (Valica) 100.1 494 |MySQL|5|6887|4049|31|180ms
495 |HSQLDB|5|6762|4063|27|138ms
496 |MySQL|1|2514|4962|27|331ms
497 |HSQLDB|1|2377|4718|21|**3.15s**
Vincent Massol 98.1 498
499 Measure set 2:
500
Eduard Moraru 111.1 501 (% class="table-bordered" style="width:100%" %)
Vincent Massol 101.2 502 |=(% width="20%" %)DB|=(% width="10%" %)Levels|=(% width="10%" %)Spaces|=(% width="10%" %)Pages|=(% width="15%" %)Requests|=Time
Ecaterina Moraru (Valica) 100.1 503 |Oracle|5|6943|4106|20|119ms
504 |Oracle|1|2493|4982|20|153ms
Vincent Massol 98.1 505
506 Measure set 3:
507
Eduard Moraru 111.1 508 (% class="table-bordered" style="width:100%" %)
Vincent Massol 101.2 509 |=(% width="20%" %)DB|=(% width="10%" %)Levels|=(% width="10%" %)Spaces|=(% width="10%" %)Pages|=(% width="15%" %)Requests|=Time
Ecaterina Moraru (Valica) 101.1 510 |Oracle|1|2485|4991|20|151ms
511 |PostgreSQL|1|2494|4991|20|125ms
Vincent Massol 98.1 512
Ilie Andriuta 103.1 513 Measure set 4 (XWiki 10.5, Intel i7 CPU, SSD Storage):
Ilie Andriuta 102.1 514
Eduard Moraru 111.1 515 (% class="table-bordered" style="width:100%" %)
Ilie Andriuta 102.1 516 |=(% width="20%" %)DB|=(% width="10%" %)Levels|=(% width="10%" %)Spaces|=(% width="10%" %)Pages|=(% width="15%" %)Requests|=Time
Ilie Andriuta 104.1 517 |PostgreSQL 10|5|6847|4052|25|74ms
Ilie Andriuta 102.1 518
Thomas Mortagne 68.1 519 = Legacy =
520
Thomas Mortagne 71.1 521 == Monitor plugin ==
Thomas Mortagne 70.1 522
523 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##:
524
525 {{code language="properties"}}
526 xwiki.monitor=0
527 {{/code}}
528
Thomas Mortagne 68.1 529 == 1.0 rendering cache using velocity in document content itself ==
530
531 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:
532
533 {{code language="none"}}
534 $context.setCacheDuration(60)
535 {{/code}}
536
537 Since 1.5M2, you can set the default rendering cache duration for all pages in ##xwiki.cfg##:
538
539 {{code language="none"}}
540 ## cache all rendered documents for one hour
541 xwiki.rendering.defaultCacheDuration=3600
542 {{/code}}
543
544 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.
Thomas Mortagne 69.1 545
Thomas Mortagne 72.1 546 == Wiki syntax features for XWiki Syntax 1.0 ==
Thomas Mortagne 69.1 547
548 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.
549
550 Now this will have no effect if you're using another syntax, like XWiki Syntax 2.x.

Get Connected