FAQ Increase Performance: Difference between revisions

From Dolibarr ERP CRM Wiki
Jump to navigation Jump to search
(Created page with "Dolibarr est une application Web qui a fait l'objet d'une conception poussée pour obtenir un temps de réponse le plus optimisé possible. De nombreuses technologies sont mises ...")
 
Tag: 2017 source edit
 
(66 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Dolibarr est une application Web qui a fait l'objet d'une conception poussée pour obtenir un temps de réponse le plus optimisé possible.
<!-- BEGIN origin interlang links -->
De nombreuses technologies sont mises en oeuvre mais certaines ne sont pas actives par défaut car nécessite des compétences ou habilitations particulières pour les mettre en oeuvre. Voici toutes les choses que vous pouvez mettre en oeuvre pour améliorer encore plus la réactivité de l'application.
<!-- You can edit this section but do NOT remove these comments
    Links below will be automatically replicated on translated pages by PolyglotBot -->
[[fr:FAQ_Améliorer_les_performances]]
[[es:FAQ_Mejorar_el_rendimiento]]
<!-- END interlang links -->


[[Category:FAQ EN]]
{{TemplateDocDevEn}}
{{TemplateDocUser}}
Dolibarr is a web application designed to have best response time.
A lot of technologies are used but some of them are not enabled by default as they need some specific skills to use them. This is a list of all possible things you can do to increase Dolibarr speed.


= Solutions recommandées =
== Désactivation de xdebug ==
Efficacité: *****


Principe: Si le module php xdebug est actif, il vous faut le désactiver. Ce module est une fonctionnalité de PHP qui sert aux développeurs mais ralentit fortement le fonctionnement de toute application PHP.
= Recommanded solutions =
Pour savoir si ce module est actif, aller dans la pages '''Accueil-Configuration-Infos systèmes-PHP''' et faites une recherche sur '''xdebug'''. Si vous ne trouvez rien, le module n'est pas actif. Si vous trouvez une occurrence, il est actif et peut être désactivé.
Son activation/désactivation dépend de votre système PHP et OS mais le plus souvent on le désactive en commentant une ligne dans le fichier php.ini


== Cache applicatif via MemCached ==
From v14, you will find into menu '''Home - Admin tools - Performances''', a page with advice on your setup to get the best performance of your application. Start with that if your version is v14+.
Efficacité: *****


Principe: Voir la page [[Module MemCached]].
You can then complete with the following recommendations...


== Cache PHP OPCODE ==
Efficacité: ****


Principe: Installer un module apache/php qui met en cache la compilation de vos pages PHP. A chaque accès, une page déjà accéder sera plus rapide d'accès.
== Use the latest PHP version ==
Pour cela vous pouvez installer n'importe quel [http://en.wikipedia.org/wiki/List_of_PHP_accelerators accélérateur PHP]. xcache fait partie des solutions recommandées.
Efficiency: ***
Notons que ce cache joue ici sur un niveau différent que le [[Module MemCached]], les gains sont donc cumulatifs !


== Cache HTTP des pages statiques ==
Principle: Each new version PHP makes application faster than the previous one. So, if you can, just upgrade.
Efficacité: ***


Principe: Vous pouvez configurer apache pour activer le cache explicite des ressources statiques en ajoutant les directives:
== Activate HTTP/2 ==
<source lang="ini">
Efficiency: *
 
Principle: HTTP/2 protocol is know to be faster than HTTP/1.1. So if your OS and webserver is compatible, just enable it.
 
== Disable xdebug ==
Efficiency: **
 
Principle: If php module xdebug is active, you should disable it. This module is a PHP feature to help developpers but it's useless for a production usage and slow down all PHP softwares.
To know if this module is active, go on page '''Home-Setup-System info-PHP''' and do a search on '''xdebug'''. If you don't find anything, module is not active. If you find an occurence, module is active and can be disabled..
Enabling/Disabling such a module depends on your PHP system and OS. The most common way is to comment a line into you php.ini and restart web server.
 
== Applicative cache using MemCached ==
Efficiency: *** (if you use a Windows server) or * (on linux server)
 
Principle: Installing a memcached server and the [[Module MemCached EN|Module MemCached]].
Note that on Linux server, the i/o are already correctly cached by the OS so this solution is efficient only on OS and filesystem with bad performances like Windows)
 
== PHP OPCODE cache ==
Efficiency: *** (if php < 7.0, useless for PHP 7.0+)
 
Principe: If you use an old PHP version, install an apache/php module that save PHP pages compilation result into a cache. Each page access will be faster. Xcache is the recommended solution.
Note that caching occurs here on a different level than [[Module MemCached]], so gains are cumulative !
 
== HTTP cache of static pages ==
Efficiency: **
 
Principle: You can setup apache to activate explicit cache of static resources by adding following directives:
<syntaxHighlight lang="ini">
# Cache for static resources (Enable expiration and set it to A2592000 = 1 month)
# Cache for static resources (Enable expiration and set it to A2592000 = 1 month)
ExpiresActive On
ExpiresActive On
Line 38: Line 64:
ExpiresByType application/x-javascript A2592000
ExpiresByType application/x-javascript A2592000
ExpiresByType application/javascript A2592000
ExpiresByType application/javascript A2592000
</source>
</syntaxHighlight>
La encore les gains sont cumulatifs avec les caches précédents.
Again, gain is cumulative with other previous caches.
 
[[File:warning.png]] After adding this, you must reload web server setup but also clear local cache browser to force browser to ask full file again and get new header.
 
== Enable compression of resources by Apache ==
Efficiency: *** (on low bandwith network)


== Utilisation du driver mysqli plutôt que mysql ==
Principle: You can setup apache to activate compression of returned resources by adding following directives:
Efficacité: ***
<syntaxHighlight lang="ini">
# Compress returned resources of type php pages, text file export, css and javascript
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/x-javascript
</syntaxHighlight>
[[File:warning.png]] After adding this, you must reload web server setup but also clear local cache browser to force browser to ask full file again and get new header.


Principe: Si vous utilisez une base de données Mysql, vérifiez dans votre fichier de configuration Dolibarr htdocs/conf/conf.php que vous avez bien la ligne
== Use mysqli driver instead of mysql ==
<source lang="php">
Efficiency: ** (for very old PHP version)
 
Principle: If you use a mysql database, check into your Dolibarr config file htdocs/conf/conf.php that you have the line
<syntaxHighlight lang="php">
$dolibarr_main_db_type='mysqli';
$dolibarr_main_db_type='mysqli';
</source>
</syntaxHighlight>
Si la valeur vaut '''mysql''', changez la en '''mysqli''' qui donne de meilleures performances (gain de 30ms à chaque page).
If value is '''mysql''', change it into '''mysqli''' that provide better performances (gain is 30ms for each page call).
 
== Search on beginning of field ==
Efficiency: * to *****


== Recherche sur début de champ ==
Principle: When you have a high number of products or third parties, you must disable the "autocomplete" search or lists will take a long time to appear. First thing to do is to go into setup of module Product and Thirdparty and change the option "Wait you have pressed n keys before loading list of product/thirdparties/contact be loading combo list". And select n = 1 or 2.
Effciacité: ***
Also, you must know that searching a ref is done everywhere in the text, so database index on field can't be used. By adding the constant PRODUCT_DONOTSEARCH_ANYWHERE to 1 into '''Home-Setup-Other''', you limit the search to the beginning of strings making possible for database to use index and you should get an immediate response. You also have the constant COMPANY_DONOTSEARCH_ANYWHERE for searches of third parties.


Principe: Si vous avez activé dans le module Produit la recherche par "autocomplete" et si la liste met du temps à apparaitre à chaque saisie de caractère, c'est que vous avez un nombre important de produit. La recherche se faisant n'importe ou dans le texte, l'index de base de donnée ne peut être utilisé. En ajoutant la constante PRODUCT_DONOTSEARCH_ANYWHERE à 1 dans '''Accueil-Configuration-Divers''', vous limiter la recherche au début de la chaine rendant possible l'utilisation de l'index et obtenez une réponse immédiate.
== Disabling combo ajax ==
Efficiency: ***


= Autres solutions =
If you have a large number of third parties, contacts or products (> 5000), you can deactivate the product preloading feature to only load the list after clicking on 1, 2 or 3 characters.
== Cache applicatif via la Shared memory ==
This is done from the configuration page of the Third Party or Product module.
Efficacité: ****


Prérequis: Utilisation du serveur web Apache
== Use a recent web browser ==
Efficiency: ***


Principe: Ajouter dans '''Accueil-Configuration-Divers''' la constante MAIN_OPTIMIZE_SPEED. Si la valeur de cette constante a le bit 1 défini (Exemple: MAIN_OPTIMIZE_SPEED=2), la shared memory de votre OS est utilisée pour mettre en cache les fichiers lang, mais cela implique aussi que tout l'interface ne sera visible que dans une seule langue, celle du premier qui se connecte après un redémarrage du serveur web (qui charge les fichiers langues en cache). Utiliser plutôt le [[Module MemCached]] pour une optimisation par un cache applicatif qui n'a aucune de ces contraintes et est encore plus performant.
Principle: More and more features used Ajax or javascript technologies to offer a modern look and feel. Such technologies are an important part of time taken to show a page and are best processed with a recent web browser. Gap between a version and the next one are sometimes very important, so think to use an optimized web browser and always the last stable version (Firefox, Chrome, Safari or Opera). Avoid IE or other exotic web browsers.


== Utilisation des versions précompressées des librairies Javascript ==
== Update your database statistics ==
Efficacité: *
Efficiency: **


Prérequis: Requiert modification de la configuration Apache.
Principle: If you use a large database (more than 100 000 records), check that statistics of data are up to date. This need an admin access to database server and some database administration knowledge. Check your database manual about "update statistics" for this.


Principe: Ajouter dans '''Accueil-Configuration-Divers''' la constante MAIN_OPTIMIZE_SPEED. Si la valeur de cette constante a le bit 0 défini (Exemple: MAIN_OPTIMIZE_SPEED=1), Dolibarr utilisera les versions pré-compressées des scripts javascripts. A utiliser si votre connexion est lente.
= Other solutions =
Le serveur Apache doit alors être configuré avec les lignes
All solutions here are categorized into an "Other solutions" because they are '''not''' recommended. All of them may needs advanced technical knowledge, may not be stable, not supported or may break some features... but they exists, so use them only if you know what you do !
<source lang="ini">
AddType text/javascript .jgz
AddEncoding gzip .jgz
</source>
Ensuite vider son cache navigateur.
Cette optimisation semble ne pas fonctionner en HTTPS (erreur de sécurité pour une raison indéterminée).


== Compression à la volée des librairies et css ==
== Disable "on fly" PDF generation ==
Efficacité: *
Efficiency: **


Principe:  Ajouter dans '''Accueil-Configuration-Divers''' la constante MAIN_OPTIMIZE_SPEED. Si la valeur de cette constante a le bit 2 défini (Exemple: MAIN_OPTIMIZE_SPEED=4), Dolibarr renverra les pages compressés en GZ (et si le navigateur le supporte). Cela consomme plus de CPU sur le serveur mais réduit le temps de transfert.
You can option MAIN_DISABLE_PDF_AUTOUPDATE into Home - Setup - Other.


This will disable generation of a new PDF each time you make a change on element. PDF generation will happens only when you click on "Generate" button.


== Disable Canvas feature ==
Efficiency: *


Rem: Pour obtenir la totalité des optimisations utilisant MAIN_OPTIMIZE_SPEED, il faut activer tous les bits (Exemple: MAIN_OPTIMIZE_SPEED=7 donc 1+2+4 contient le bit 0, 1 et 2).
Principle: Add into '''Home-Setup-Other''' the constant MAIN_DISABLE_CANVAS to value 1. This will disable canvas features that might be used by external modules and save one database request each time you go on page to show an object.
However, if an external module used canvas, this will break this module. If you did not install and do not plan to install a complementary external modules, using this setup is safe.

Latest revision as of 13:20, 27 February 2023

Dolibarr is a web application designed to have best response time. A lot of technologies are used but some of them are not enabled by default as they need some specific skills to use them. This is a list of all possible things you can do to increase Dolibarr speed.


Recommanded solutions

From v14, you will find into menu Home - Admin tools - Performances, a page with advice on your setup to get the best performance of your application. Start with that if your version is v14+.

You can then complete with the following recommendations...


Use the latest PHP version

Efficiency: ***

Principle: Each new version PHP makes application faster than the previous one. So, if you can, just upgrade.

Activate HTTP/2

Efficiency: *

Principle: HTTP/2 protocol is know to be faster than HTTP/1.1. So if your OS and webserver is compatible, just enable it.

Disable xdebug

Efficiency: **

Principle: If php module xdebug is active, you should disable it. This module is a PHP feature to help developpers but it's useless for a production usage and slow down all PHP softwares. To know if this module is active, go on page Home-Setup-System info-PHP and do a search on xdebug. If you don't find anything, module is not active. If you find an occurence, module is active and can be disabled.. Enabling/Disabling such a module depends on your PHP system and OS. The most common way is to comment a line into you php.ini and restart web server.

Applicative cache using MemCached

Efficiency: *** (if you use a Windows server) or * (on linux server)

Principle: Installing a memcached server and the Module MemCached. Note that on Linux server, the i/o are already correctly cached by the OS so this solution is efficient only on OS and filesystem with bad performances like Windows)

PHP OPCODE cache

Efficiency: *** (if php < 7.0, useless for PHP 7.0+)

Principe: If you use an old PHP version, install an apache/php module that save PHP pages compilation result into a cache. Each page access will be faster. Xcache is the recommended solution. Note that caching occurs here on a different level than Module MemCached, so gains are cumulative !

HTTP cache of static pages

Efficiency: **

Principle: You can setup apache to activate explicit cache of static resources by adding following directives:

# Cache for static resources (Enable expiration and set it to A2592000 = 1 month)
ExpiresActive On
ExpiresByType image/x-icon A2592000
ExpiresByType image/gif A2592000
ExpiresByType image/png A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType text/css A2592000
ExpiresByType text/javascript A2592000
ExpiresByType application/x-javascript A2592000
ExpiresByType application/javascript A2592000

Again, gain is cumulative with other previous caches.

Warning.png After adding this, you must reload web server setup but also clear local cache browser to force browser to ask full file again and get new header.

Enable compression of resources by Apache

Efficiency: *** (on low bandwith network)

Principle: You can setup apache to activate compression of returned resources by adding following directives:

# Compress returned resources of type php pages, text file export, css and javascript
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/x-javascript

Warning.png After adding this, you must reload web server setup but also clear local cache browser to force browser to ask full file again and get new header.

Use mysqli driver instead of mysql

Efficiency: ** (for very old PHP version)

Principle: If you use a mysql database, check into your Dolibarr config file htdocs/conf/conf.php that you have the line

$dolibarr_main_db_type='mysqli';

If value is mysql, change it into mysqli that provide better performances (gain is 30ms for each page call).

Search on beginning of field

Efficiency: * to *****

Principle: When you have a high number of products or third parties, you must disable the "autocomplete" search or lists will take a long time to appear. First thing to do is to go into setup of module Product and Thirdparty and change the option "Wait you have pressed n keys before loading list of product/thirdparties/contact be loading combo list". And select n = 1 or 2. Also, you must know that searching a ref is done everywhere in the text, so database index on field can't be used. By adding the constant PRODUCT_DONOTSEARCH_ANYWHERE to 1 into Home-Setup-Other, you limit the search to the beginning of strings making possible for database to use index and you should get an immediate response. You also have the constant COMPANY_DONOTSEARCH_ANYWHERE for searches of third parties.

Disabling combo ajax

Efficiency: ***

If you have a large number of third parties, contacts or products (> 5000), you can deactivate the product preloading feature to only load the list after clicking on 1, 2 or 3 characters. This is done from the configuration page of the Third Party or Product module.

Use a recent web browser

Efficiency: ***

Principle: More and more features used Ajax or javascript technologies to offer a modern look and feel. Such technologies are an important part of time taken to show a page and are best processed with a recent web browser. Gap between a version and the next one are sometimes very important, so think to use an optimized web browser and always the last stable version (Firefox, Chrome, Safari or Opera). Avoid IE or other exotic web browsers.

Update your database statistics

Efficiency: **

Principle: If you use a large database (more than 100 000 records), check that statistics of data are up to date. This need an admin access to database server and some database administration knowledge. Check your database manual about "update statistics" for this.

Other solutions

All solutions here are categorized into an "Other solutions" because they are not recommended. All of them may needs advanced technical knowledge, may not be stable, not supported or may break some features... but they exists, so use them only if you know what you do !

Disable "on fly" PDF generation

Efficiency: **

You can option MAIN_DISABLE_PDF_AUTOUPDATE into Home - Setup - Other.

This will disable generation of a new PDF each time you make a change on element. PDF generation will happens only when you click on "Generate" button.

Disable Canvas feature

Efficiency: *

Principle: Add into Home-Setup-Other the constant MAIN_DISABLE_CANVAS to value 1. This will disable canvas features that might be used by external modules and save one database request each time you go on page to show an object. However, if an external module used canvas, this will break this module. If you did not install and do not plan to install a complementary external modules, using this setup is safe.