Wiki source code of Performance
Last modified by Thomas Mortagne on 2024/09/04
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | {{box cssClass="floatinginfobox" title="**Contents**"}} | ||
2 | {{toc/}} | ||
3 | {{/box}} | ||
4 | |||
5 | Here are some tips to increase XWiki's performance. | ||
6 | |||
7 | = Clustering = | ||
8 | |||
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. | ||
10 | |||
11 | = Standalone Solr = | ||
12 | |||
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. | ||
15 | |||
16 | See [[Performance Guide in Solr module documentation>>extensions:Extension.Solr Search API#HPerformances]]. | ||
17 | |||
18 | = Gzip compression and caching of static pages = | ||
19 | |||
20 | 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. | ||
21 | |||
22 | Many application servers (Tomcat, etc.) and HTTP proxies (Apache HTTPd, Nginx, etc.) support it. | ||
23 | |||
24 | == In Apache HTTP Server == | ||
25 | |||
26 | The recommended solution is to set up an Apache Web Server in front of your servlet container and install/configure the following modules: | ||
27 | |||
28 | * [[mod-deflate>>http://httpd.apache.org/docs/2.0/mod/mod_deflate.html]] | ||
29 | * [[mod-expires>>http://httpd.apache.org/docs/2.0/mod/mod_expires.html]] | ||
30 | * [[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) | ||
31 | |||
32 | Modify your Apache configuration file to load the different modules: | ||
33 | |||
34 | {{code language="none"}} | ||
35 | LoadModule expires_module /usr/lib/apache2/modules/mod_expires.so | ||
36 | LoadModule deflate_module /usr/lib/apache2/modules/mod_deflate.so | ||
37 | LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so | ||
38 | # Depends: proxy | ||
39 | LoadModule proxy_ajp_module /usr/lib/apache2/modules/mod_proxy_ajp.so | ||
40 | {{/code}} | ||
41 | |||
42 | //Alternatively you can run the following commands as root (sudo)// | ||
43 | |||
44 | {{code language="bash"}} | ||
45 | a2enmod deflate | ||
46 | a2enmod proxy_ajp | ||
47 | a2enmod expires | ||
48 | {{/code}} | ||
49 | |||
50 | and configure your different modules as described below: | ||
51 | |||
52 | === Mod Deflate Configuration === | ||
53 | |||
54 | {{code language="none"}} | ||
55 | vwwwpro-1:~# cat /etc/apache2/conf.d/deflate | ||
56 | <Location ></Location> | ||
57 | # Insert filter | ||
58 | SetOutputFilter DEFLATE | ||
59 | |||
60 | # Netscape 4.x has some problems... | ||
61 | BrowserMatch ^Mozilla/4 gzip-only-text/html | ||
62 | |||
63 | # Netscape 4.06-4.08 have some more problems | ||
64 | BrowserMatch ^Mozilla/4.0[678] no-gzip | ||
65 | |||
66 | # MSIE masquerades as Netscape, but it is fine | ||
67 | # BrowserMatch bMSIE !no-gzip !gzip-only-text/html | ||
68 | |||
69 | # NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48 | ||
70 | # the above regex won't work. You can use the following | ||
71 | # workaround to get the desired effect: | ||
72 | BrowserMatch bMSI[E] !no-gzip !gzip-only-text/html | ||
73 | |||
74 | # Don't compress images | ||
75 | SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary | ||
76 | |||
77 | # Make sure proxies don't deliver the wrong content | ||
78 | #Header append Vary User-Agent env=!dont-vary | ||
79 | </Location> | ||
80 | {{/code}} | ||
81 | |||
82 | //On debian apache2 the config file for deflate is located under /etc/apache2/mods-enabled/deflate.conf// | ||
83 | |||
84 | === Mod Expire Configuration === | ||
85 | |||
86 | {{code language="none"}} | ||
87 | vwwwpro-1:~# cat /etc/apache2/conf.d/expires | ||
88 | <Location /xwiki/skins></Location> | ||
89 | ExpiresActive on | ||
90 | ExpiresDefault "access plus 1 day" | ||
91 | </Location> | ||
92 | |||
93 | <Location /xwiki/bin/skin></Location> | ||
94 | ExpiresActive on | ||
95 | ExpiresDefault "access plus 1 day" | ||
96 | </Location> | ||
97 | {{/code}} | ||
98 | |||
99 | === Mod Proxy AJP Configuration === | ||
100 | |||
101 | {{code language="none"}} | ||
102 | ProxyRequests Off | ||
103 | <Proxy *> | ||
104 | Order deny,allow | ||
105 | Allow from all | ||
106 | </Proxy> | ||
107 | ProxyPreserveHost On | ||
108 | ProxyPass /xwiki ajp://192.168.1.181:8009/xwiki | ||
109 | {{/code}} | ||
110 | |||
111 | where {{code}}ajp://192.168.1.181:8009/xwiki{{/code}} is the internal address of your Servlet container where XWiki is running. | ||
112 | |||
113 | 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 ##<!~-~- ~-~->##. | ||
114 | |||
115 | {{code}} | ||
116 | <!-- Disable to use ajp connector instead | ||
117 | <Connector port="8080" | ||
118 | protocol="HTTP/1.1" | ||
119 | connectionTimeout="20000" | ||
120 | URIEncoding="UTF-8" | ||
121 | redirectPort="8443"> | ||
122 | </Connector> | ||
123 | --> | ||
124 | {{/code}} | ||
125 | |||
126 | Uncomment the following line by removing the ##<!~-~- ~-~->## and add {{code}}URIEncoding="UTF-8"{{/code}} to it. | ||
127 | |||
128 | {{code}} | ||
129 | <!-- Activate ajp connector for apache proxy_ajp --> | ||
130 | <Connector port="8009" | ||
131 | protocol="AJP/1.3" | ||
132 | redirectPort="8443" | ||
133 | URIEncoding="UTF-8"> | ||
134 | </Connector> | ||
135 | {{/code}} | ||
136 | |||
137 | = Memory = | ||
138 | |||
139 | 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. | ||
140 | |||
141 | Here are some good default values: | ||
142 | |||
143 | * Small and medium installs: A minimum of 1024MB (##-Xmx1024m)## | ||
144 | * Large installs: 2048MB or beyond (##-Xmx2048m)## | ||
145 | |||
146 | {{info}} | ||
147 | 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). | ||
148 | {{/info}} | ||
149 | |||
150 | {{warning}} | ||
151 | 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. | ||
152 | {{/warning}} | ||
153 | |||
154 | For your information here are the values used for the xwiki.org site: | ||
155 | |||
156 | {{code}} | ||
157 | 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" | ||
158 | {{/code}} | ||
159 | |||
160 | = Sizing = | ||
161 | |||
162 | 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: | ||
163 | |||
164 | * 2GB of RAM (See [[XWiki memory needs>>#HMemory]]), | ||
165 | * 2 cores((( | ||
166 | {{code language="none"}} | ||
167 | AMD Opteron(tm) Processor 6386 SE | ||
168 | cpu MHz : 2800.000 | ||
169 | cache size : 2048 KB | ||
170 | {{/code}} | ||
171 | ))) | ||
172 | * 16GB disk size by default | ||
173 | |||
174 | = Database Indexes = | ||
175 | |||
176 | Make sure you've set [[Database indexes>>Documentation.AdminGuide.Performances.Database Administration.WebHome]]. This is especially important when you start having lots of documents. | ||
177 | |||
178 | = Large number of users = | ||
179 | |||
180 | 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: | ||
181 | |||
182 | {{code language="none"}} | ||
183 | xwiki.authentication.group.allgroupimplicit=1 | ||
184 | {{/code}} | ||
185 | |||
186 | 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). | ||
187 | |||
188 | 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): | ||
189 | |||
190 | {{code language="none"}} | ||
191 | #-# List of groups that a new user should be added to by default after registering. Comma-separated list of group | ||
192 | #-# document names. | ||
193 | # xwiki.users.initialGroups=XWiki.XWikiAllGroup | ||
194 | {{/code}} | ||
195 | |||
196 | = Robots.txt = | ||
197 | |||
198 | 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. | ||
199 | |||
200 | Some example: | ||
201 | |||
202 | {{code language="none"}} | ||
203 | User-agent: * | ||
204 | # Prevent bots from executing all actions except "view" since: | ||
205 | # 1) we don't want bots to execute stuff in the wiki! | ||
206 | # 2) we don't want bots to consume CPU and memory | ||
207 | # (for example to perform exports) | ||
208 | # Note: You may want to allow /download/ if you wish to have | ||
209 | # attachments indexed. | ||
210 | # Note2: Using * instead of /bin/ to also match path-based | ||
211 | # subwikis like "/xwiki/wiki/wikialias/view/Space/Page" | ||
212 | Disallow: /xwiki/*/viewattachrev/ | ||
213 | Disallow: /xwiki/*/viewrev/ | ||
214 | Disallow: /xwiki/*/pdf/ | ||
215 | Disallow: /xwiki/*/tex/ | ||
216 | Disallow: /xwiki/*/edit/ | ||
217 | Disallow: /xwiki/*/create/ | ||
218 | Disallow: /xwiki/*/inline/ | ||
219 | Disallow: /xwiki/*/preview/ | ||
220 | Disallow: /xwiki/*/save/ | ||
221 | Disallow: /xwiki/*/saveandcontinue/ | ||
222 | Disallow: /xwiki/*/rollback/ | ||
223 | Disallow: /xwiki/*/deleteversions/ | ||
224 | Disallow: /xwiki/*/cancel/ | ||
225 | Disallow: /xwiki/*/delete/ | ||
226 | Disallow: /xwiki/*/deletespace/ | ||
227 | Disallow: /xwiki/*/undelete/ | ||
228 | Disallow: /xwiki/*/reset/ | ||
229 | Disallow: /xwiki/*/register/ | ||
230 | Disallow: /xwiki/*/propupdate/ | ||
231 | Disallow: /xwiki/*/propadd/ | ||
232 | Disallow: /xwiki/*/propdisable/ | ||
233 | Disallow: /xwiki/*/propenable/ | ||
234 | Disallow: /xwiki/*/propdelete/ | ||
235 | Disallow: /xwiki/*/objectadd/ | ||
236 | Disallow: /xwiki/*/commentadd/ | ||
237 | Disallow: /xwiki/*/commentsave/ | ||
238 | Disallow: /xwiki/*/objectsync/ | ||
239 | Disallow: /xwiki/*/objectremove/ | ||
240 | Disallow: /xwiki/*/attach/ | ||
241 | Disallow: /xwiki/*/upload/ | ||
242 | Disallow: /xwiki/*/download/ | ||
243 | Disallow: /xwiki/*/temp/ | ||
244 | Disallow: /xwiki/*/downloadrev/ | ||
245 | Disallow: /xwiki/*/dot/ | ||
246 | Disallow: /xwiki/*/svg/ | ||
247 | Disallow: /xwiki/*/delattachment/ | ||
248 | Disallow: /xwiki/*/skin/ | ||
249 | Disallow: /xwiki/*/jsx/ | ||
250 | Disallow: /xwiki/*/ssx/ | ||
251 | Disallow: /xwiki/*/login/ | ||
252 | Disallow: /xwiki/*/loginsubmit/ | ||
253 | Disallow: /xwiki/*/loginerror/ | ||
254 | Disallow: /xwiki/*/logout/ | ||
255 | Disallow: /xwiki/*/charting/ | ||
256 | Disallow: /xwiki/*/lock/ | ||
257 | Disallow: /xwiki/*/redirect/ | ||
258 | Disallow: /xwiki/*/admin/ | ||
259 | Disallow: /xwiki/*/export/ | ||
260 | Disallow: /xwiki/*/import/ | ||
261 | Disallow: /xwiki/*/get/ | ||
262 | Disallow: /xwiki/*/distribution/ | ||
263 | Disallow: /xwiki/*/imagecaptcha/ | ||
264 | Disallow: /xwiki/*/unknown/ | ||
265 | # Note: In addition, this matches both old /xwiki/bin/webjars/ | ||
266 | # and new /xwiki/webjars paths. | ||
267 | Disallow: /xwiki/*/webjars/ | ||
268 | # Don't index additional UI-related resources. | ||
269 | Disallow: /xwiki/resources/ | ||
270 | # Don't index sandbox content since it's sample content | ||
271 | Disallow: /xwiki/*/view/Sandbox/ | ||
272 | # Don't index Admin space since it contains Admin stuff. | ||
273 | # Note that the Admin space is protected by permissions | ||
274 | # anyway but this acts as a safety net to not have private | ||
275 | # info leaked on the internet ;) | ||
276 | Disallow: /xwiki/*/view/Admin/ | ||
277 | # Don't index Stats data (just because it's not useful and | ||
278 | # those pages are a bit CPU intensive) | ||
279 | Disallow: /xwiki/*/view/Stats/ | ||
280 | # Don't index Panels data (because we don't want it | ||
281 | # indexed on the internet) | ||
282 | Disallow: /xwiki/*/view/Panels/ | ||
283 | # Don't index the search page. | ||
284 | Disallow: /xwiki/*/Main/Search | ||
285 | # Don't index the REST API. | ||
286 | Disallow: /xwiki/rest/ | ||
287 | # These are just UI elements which can cause infinite loops in | ||
288 | # web crawlers. See https://jira.xwiki.org/browse/XWIKI-16915 | ||
289 | Disallow: /xwiki/*?*xpage=* | ||
290 | {{/code}} | ||
291 | |||
292 | Other example: | ||
293 | |||
294 | {{code}} | ||
295 | [...] | ||
296 | # It could be also useful to block certain spaces from crawling, | ||
297 | # especially if this spaces doesn't provide new content | ||
298 | Disallow: /xwiki/bin/view/Main/ | ||
299 | Disallow: /xwiki/bin/view/XWiki/ | ||
300 | # On the other hand you would like to have your recent (public) changes included | ||
301 | Allow: /xwiki/bin/view/Main/Dashboard | ||
302 | {{/code}} | ||
303 | |||
304 | **Note:** | ||
305 | |||
306 | For Tomcat6 the placement of the ##robots.txt## file should be within the //$TOMCAT/webapps/ROOT// folder and should have permission 644 applied. | ||
307 | |||
308 | {{code}} | ||
309 | -rw-r--r-- 1 root www 1478 Jan 8 15:52 robots.txt | ||
310 | {{/code}} | ||
311 | |||
312 | == Indexing JS and CSS == | ||
313 | |||
314 | [[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. | ||
315 | |||
316 | In this case, you might want to make sure to **remove** the following ##Disallow## entries from your robots.txt file: | ||
317 | |||
318 | {{code language="none"}} | ||
319 | Disallow: /xwiki/*/skin/ | ||
320 | Disallow: /xwiki/*/jsx/ | ||
321 | Disallow: /xwiki/*/ssx/ | ||
322 | Disallow: /xwiki/*/webjars/ | ||
323 | Disallow: /xwiki/*/resources/ | ||
324 | {{/code}} | ||
325 | |||
326 | == Indexing images == | ||
327 | |||
328 | For images uploaded as attachments inside wiki pages, you should **add** the following ##Allow## entries for the ##/download/## action: | ||
329 | |||
330 | {{code language="none"}} | ||
331 | Allow: /xwiki/*/download/*.png$ | ||
332 | Allow: /xwiki/*/download/*.jpg$ | ||
333 | Allow: /xwiki/*/download/*.jpeg$ | ||
334 | Allow: /xwiki/*/download/*.gif$ | ||
335 | {{/code}} | ||
336 | |||
337 | |||
338 | 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/]]. | ||
339 | |||
340 | = Statistics = | ||
341 | |||
342 | {{info}} | ||
343 | 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. | ||
344 | {{/info}} | ||
345 | |||
346 | The statistics module is off by default since it's quite database intensive. If you don't need it you should turn it off. | ||
347 | The current recommendation is to use the [[Matomo extension>>extensions:Extension.Piwiki Integration]] for statistics instead. | ||
348 | |||
349 | = Document Cache = | ||
350 | |||
351 | 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). | ||
352 | |||
353 | {{code language="none"}} | ||
354 | xwiki.store.cache.capacity=1000 | ||
355 | {{/code}} | ||
356 | |||
357 | = Cache Macro = | ||
358 | |||
359 | It's possible to perform selective content caching by using the [[Cache Macro>>extensions:Extension.Cache Macro]]. | ||
360 | |||
361 | = LESS CSS Performances = | ||
362 | |||
363 | [[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. | ||
364 | |||
365 | = Rendering cache = | ||
366 | |||
367 | 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. | ||
368 | |||
369 | The configuration is done in ##xwiki.properties## with the following configuration options: | ||
370 | |||
371 | {{code language="none"}} | ||
372 | #-# [Since 2.4M1] | ||
373 | #-# Indicate if the rendering cache is enabled. | ||
374 | #-# Default value is false. | ||
375 | # core.renderingcache.enabled=true | ||
376 | |||
377 | #-# [Since 2.4M1] | ||
378 | #-# A list of Java regex patterns matching full documents reference. | ||
379 | # core.renderingcache.documents=wiki:Space\.Page | ||
380 | # core.renderingcache.documents=wiki:Space\..* | ||
381 | |||
382 | #-# [Since 2.4M1] | ||
383 | #-# The time (in seconds) after which data should be removed from the cache when not used. | ||
384 | #-# Default value is 300 (5 min). | ||
385 | # core.renderingcache.duration=300 | ||
386 | |||
387 | #-# [Since 2.4M1] | ||
388 | #-# The size of the rendering cache. Not that it's not the number of cached documents but the number of cached results. | ||
389 | #-# (For a single document several cache entries are created, because each action, language and request query string | ||
390 | #-# produces a unique rendering result) | ||
391 | #-# Default value is 100. | ||
392 | # core.renderingcache.size=100 | ||
393 | {{/code}} | ||
394 | |||
395 | You can force a page to refresh using ##refresh=1## in the URL. | ||
396 | |||
397 | It's also possible to programmatically refresh any document cache using ##com.xpn.xwiki.internal.cache.rendering.RenderingCache## component: | ||
398 | |||
399 | {{code language="java"}} | ||
400 | @Inject | ||
401 | private RenderingCache renderingCache; | ||
402 | |||
403 | ... | ||
404 | |||
405 | renderingCache.flushWholeCache(); | ||
406 | renderingCache.flushCache(new DocumentReference("xwiki", "MySpace", "MyCachedDocument")); | ||
407 | {{/code}} | ||
408 | |||
409 | = Merge the CSS files = | ||
410 | |||
411 | 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]]. | ||
412 | |||
413 | = Set up NginX = | ||
414 | |||
415 | If you experience //__heavy loads__// on your wiki, you could try using NginX. | ||
416 | |||
417 | 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). | ||
418 | |||
419 | 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". | ||
420 | |||
421 | For more info on setting up NginX check [[this guide>>Documentation.AdminGuide.Installation.NginX.WebHome]]. | ||
422 | |||
423 | = Local resource access = | ||
424 | |||
425 | [[See URL API>>extensions:Extension.URL API#HResourcemodificationdate]]. | ||
426 | |||
427 | = Backlinks = | ||
428 | |||
429 | 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##: | ||
430 | |||
431 | {{code language="none"}} | ||
432 | xwiki.backlinks=0 | ||
433 | {{/code}} | ||
434 | |||
435 | = Versioning = | ||
436 | |||
437 | 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##: | ||
438 | |||
439 | {{code language="none"}} | ||
440 | xwiki.store.versioning=0 | ||
441 | {{/code}} | ||
442 | |||
443 | = Custom Mapping = | ||
444 | |||
445 | 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]]. | ||
446 | |||
447 | = LDAP = | ||
448 | |||
449 | == Disable LDAP sub groups search == | ||
450 | |||
451 | 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. | ||
452 | |||
453 | = Performance tree = | ||
454 | |||
455 | 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]]. | ||
456 | |||
457 | = Navigation Tree = | ||
458 | |||
459 | 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: | ||
460 | |||
461 | Measure set 1: | ||
462 | |||
463 | (% class="table-bordered" style="width:100%" %) | ||
464 | |=(% width="20%" %)DB|=(% width="10%" %)Levels|=(% width="10%" %)Spaces|=(% width="10%" %)Pages|=(% width="15%" %)Requests|=Time | ||
465 | |MySQL|5|6887|4049|31|180ms | ||
466 | |HSQLDB|5|6762|4063|27|138ms | ||
467 | |MySQL|1|2514|4962|27|331ms | ||
468 | |HSQLDB|1|2377|4718|21|**3.15s** | ||
469 | |||
470 | Measure set 2: | ||
471 | |||
472 | (% class="table-bordered" style="width:100%" %) | ||
473 | |=(% width="20%" %)DB|=(% width="10%" %)Levels|=(% width="10%" %)Spaces|=(% width="10%" %)Pages|=(% width="15%" %)Requests|=Time | ||
474 | |Oracle|5|6943|4106|20|119ms | ||
475 | |Oracle|1|2493|4982|20|153ms | ||
476 | |||
477 | Measure set 3: | ||
478 | |||
479 | (% class="table-bordered" style="width:100%" %) | ||
480 | |=(% width="20%" %)DB|=(% width="10%" %)Levels|=(% width="10%" %)Spaces|=(% width="10%" %)Pages|=(% width="15%" %)Requests|=Time | ||
481 | |Oracle|1|2485|4991|20|151ms | ||
482 | |PostgreSQL|1|2494|4991|20|125ms | ||
483 | |||
484 | Measure set 4 (XWiki 10.5, Intel i7 CPU, SSD Storage): | ||
485 | |||
486 | (% class="table-bordered" style="width:100%" %) | ||
487 | |=(% width="20%" %)DB|=(% width="10%" %)Levels|=(% width="10%" %)Spaces|=(% width="10%" %)Pages|=(% width="15%" %)Requests|=Time | ||
488 | |PostgreSQL 10|5|6847|4052|25|74ms | ||
489 | |||
490 | = Legacy = | ||
491 | |||
492 | == Slow random number generation on UNIX = | ||
493 | |||
494 | {{info}} | ||
495 | 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. | ||
496 | {{/info}} | ||
497 | |||
498 | The library used for random number generation in Oracle's JVM relies on ##/dev/random## by default for UNIX platforms. | ||
499 | |||
500 | Although ##/dev/random## is more secure, it's possible to use ##/dev/urandom## if the default JVM configuration instead. | ||
501 | |||
502 | To determine if your operating system exhibits this behavior, try displaying a portion of the file from a shell prompt: | ||
503 | |||
504 | {{code language="bash"}} | ||
505 | head -n 1 /dev/random | ||
506 | {{/code}} | ||
507 | |||
508 | 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##: | ||
509 | |||
510 | === JVM setup == | ||
511 | |||
512 | 1. Open the ##$JAVA_HOME/jre/lib/security/java.security## file in a text editor. | ||
513 | 1. Change the line: | ||
514 | {{code language="properties"}} securerandom.source=file:/dev/random{{/code}} | ||
515 | to read: | ||
516 | {{code language="properties"}} securerandom.source=file:/dev/urandom{{/code}} | ||
517 | 1. Save your change and exit the text editor. | ||
518 | |||
519 | == Command line parameter == | ||
520 | |||
521 | The same effect can be obtained using ##-Djava.security.egd=file:/dev/./urandom## in the Java command line (usually in the application server configuration). | ||
522 | |||
523 | == Monitor plugin == | ||
524 | |||
525 | 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##: | ||
526 | |||
527 | {{code language="properties"}} | ||
528 | xwiki.monitor=0 | ||
529 | {{/code}} | ||
530 | |||
531 | == 1.0 rendering cache using velocity in document content itself == | ||
532 | |||
533 | 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: | ||
534 | |||
535 | {{code language="none"}} | ||
536 | $context.setCacheDuration(60) | ||
537 | {{/code}} | ||
538 | |||
539 | Since 1.5M2, you can set the default rendering cache duration for all pages in ##xwiki.cfg##: | ||
540 | |||
541 | {{code language="none"}} | ||
542 | ## cache all rendered documents for one hour | ||
543 | xwiki.rendering.defaultCacheDuration=3600 | ||
544 | {{/code}} | ||
545 | |||
546 | 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. | ||
547 | |||
548 | == Wiki syntax features for XWiki Syntax 1.0 == | ||
549 | |||
550 | 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. | ||
551 | |||
552 | Now this will have no effect if you're using another syntax, like XWiki Syntax 2.x. |