Merge pull request #782 from balderino/master

Doc - Improve Performance
This commit is contained in:
Tobias Diekershoff 2013-10-07 21:33:33 -07:00
commit a8861dabcd
4 changed files with 297 additions and 0 deletions

View File

@ -18,6 +18,7 @@ Friendica Documentation and Resources
* [Community Forums](help/Forums)
* [Chats](help/Chats)
* Further information
* [Improve Performance](help/Improve-Performance)
* [Move Account](help/Move-Account)
* [Remove Account](help/Remove-Account)
* [Bugs and Issues](help/Bugs-and-Issues)

148
doc/Improve-Performance.md Normal file
View File

@ -0,0 +1,148 @@
How to: improve performance
==============
* [Home](help)
A little guide to increase the performance of a Friendica site
**At first**
Feel free to ask at Friendica support at https://helpers.pyxis.uberspace.de/profile/helpers if you need some clarification about the following instructions or if you need help in any other way.
System configuration
--------
Please go to /admin/site/ on your system and change the following values:
Set "JPEG image quality" to 50.
This value reduces the data that is send from the server to the client. 50 is a value that doesn't influences image quality too much.
Set "OStatus conversation completion interval" to "never".
If you have many OStatus contacts then completing of conversations can be very time wasting. The downside: You won't see every comment in OStatus threads.
Set "Path for lock file" to an empty folder outside your web root.
Lock files help avoid the possibility of several background processes running at the same time.
For example: It can happen that the poller.php takes longer than expected. When there is no lock file, it is possible for several instances of poller.php to run at the same time - which would slow down the system and affect the maximum numbers of processes and database connections.
Please define a full file path that is writeable by the web server process. If your site is located at "/var/www/sitename/htdocs/" you could maybe create a folder "/var/www/sitename/temp/".
Enable "Use MySQL full text engine"
When using MyISAM (default) this speeds up search.
Set "Path to item cache" to an empty value outside your web root.
Parsed BBCode and some external images will be put there. Parsing BBCode is a time wasting process that also makes heave use of the CPU.
You can use the same folder you used for the lock file.
**Warning!**
The folder for item cache is cleaned up regularly. Every file that exceeds the cache duration is deleted. **If you accidentally point the cache path to your web root then you will delete your web root!**
So double check that the folder only contains temporary content that can be deleted at any time.
You have been warned.
P.S. It happened to me :)
Plugins
--------
Active the following plugins:
Alternate Pagination
Privacy Image Cache
rendertime
###Alternate Pagination
**Description**
This plugin reduces the database load massively. Downside: You can't see the total number of pages available at each module, and have this replaced with "older" and "newer" links.
**Administration**
Go to the admin settings of "altpager" and set it to "global".
###Privacy Image Cache
**Description**
This plugin pre-fetches external content and stores it in the cache. Besides speeding up the page rendering it is also good for the privacy of your users, since embedded pictures are loaded from your site and not from a foreign site (that could spy on the IP addresses).
Additionally it helps with content from external sites that have slow performance or aren not online all the time.
**Administration**
Please create a folder named "privacy_image_cache" and "photo" in your web root. If these folders exists then the cached files will be stored there. This has the great advantage that your web server will fetch the files directly from there.
###rendertime
This plugin doesn't speed up your system. It helps analyzing your bottlenecks.
When enabled you see some values like the following at the bottom of every page:
Performance: Database: 0.244, Network: 0.002, Rendering: 0.044, Parser: 0.001, I/O: 0.021, Other: 0.237, Total: 0.548
Database: This is the time for all database queries
Network: Time that is needed to fetch content from external sites
Rendering: Time for theme rendering
Parser: The time that the BBCode parser needed to create the output
I/O: Time for local file access
Others: Everything else :)
Total: The sum of all above values
These values show your performance problems.
Webserver
--------
If you are using Apache please enable the following modules.
**Cache-Control**
This module tells the client to cache the content of static files so that they aren't fetched with every request.
Enable the module "mod_expires" by typing in "a2enmod expires" as root.
Please add the following lines to your site configuration in the "directory" context.
ExpiresActive on ExpiresDefault "access plus 1 week"
See also: http://httpd.apache.org/docs/2.2/mod/mod_expires.html
**Compress content**
This module compresses the traffic between the web server and the client.
Enable the module "mod_deflate" by typing in "a2enmod deflate" as root.
See also: http://httpd.apache.org/docs/2.2/mod/mod_deflate.html
PHP
--------
**FCGI**
When using apache think about using FCGI. When using a Debian based distribution you will need the packages named "php5-cgi" and "libapache2-mod-fcgid".
Please refer to external documentations for a more detailed explanation how to set up a system based upon FCGI.
**APC**
APC is an opcode cache. It speeds up the processing of PHP code.
When APC is enabled, Friendica uses it to store configuration data between different requests. This helps speeding up the page creation time.
**Database**
There are scripts like [tuning-primer.sh](http://www.day32.com/MySQL/) and [mysqltuner.pl](http://mysqltuner.pl) that analyzes your database server and give hints on values that could be changed.
Please enable the slow query log. This helps being aware of performance problems.

View File

@ -17,6 +17,7 @@ Friendica - Dokumentation und Ressourcen
* [Community-Foren](help/Forums)
* [Chats](help/Chats)
* Weiterführende Informationen
* [Performance verbessern](help/Improve-Performance)
* [Account umziehen](help/Move-Account)
* [Account löschen](help/Remove-Account)
* [Bugs und Probleme](help/Bugs-and-Issues)

View File

@ -0,0 +1,147 @@
How-to: Performance verbessern
==========
* [Zur Startseite der Hilfe](help)
Eine kleine Anleitung, um die Performance einer Friendica-Seite zu verbessern.
**Vorab:**
Wenn du Fragen zu den folgenden Anweisungen oder zu anderen Themen hast, dann kannst du jederzeit beim Friendica-Support unter https://helpers.pyxis.uberspace.de/profile/helpers nachfragen.
Systemeinstellungen
---------------
Geh auf /admin/site in deinem System und ändere die folgenden Werte:
setze "Qualität des JPEG Bildes" auf 50.
Dieser Wert reduziert die Daten, die vom Server an den Client geschickt werden. 50 ist ein Wert, der die Bildqualität nicht zu stark beeinflusst.
setze "Intervall zum Vervollständigen von OStatus Unterhaltungen" auf "niemals"
Wenn du viele OStatus-Kontakte hast, dann kann die Vervollständigung von Unterhaltungen sehr zeitraubend sein. Der Nachteil: Du siehst nicht jede Antwort einer OStatus-Unterhaltung.
setze "Pfad für die Sperrdatei" auf einen Ordner außerhalb deines Stammverzeichnisses deines Servers.
Sperrdateien sorgen dafür, dass Hintergrundprozesse nicht parallel ablaufen.
Als Beispiel: Es kann passieren, dass die poller.php länger als erwartet läuft. Ohne Sperrdatei kann es passieren, dass mehrere Instanzen der poller.php zur gleichen Zeit laufen. Dies würde das System verlangsamen und Einfluss auf die maximale Anzahl an Prozessen und Datenbankverbindungen nehmen.
Bitte definiere einen kompletten Pfad, auf den der Server einen Schreibzugriff hat. Wenn deine Seite unter "/var/www/namederseite/htdocs/" liegt, dann kannst du z.B. einen Ordner unter "/var/www/sitename/temp/" erstellen.
setze "Nutze MySQL full text engine".
Wenn du MyISAM (Standardeinstellung) nutzt, dann beschleunigt dies die Suche.
setze "Pfad zum Eintrag Cache" auf einen leeren Ordner außerhalb deines Stammverzeichnisses.
Verarbeiteter BBCode und einige externe Bilder werden hier gespeichert. BBCode verarbeiten ist ein zeitintensiver Prozess, der zudem eine hohe CPU-Leistung erfordert.
Du kannst den gleichen Ordner nutzen, den du für die Sperrdatei genutzt hast.
**Warnung!**
Der Ordner für den Eintrag-Cache wird regelmäßig geleert. Jede Datei, die die Cache-Dauer überschreitet, wird gelöscht. **Wenn du versehentlich den Cache-Pfad auf dein Stammverzeichnis legst, dann würde dir dies das gesamte Stammverzeichnis löschen.**
Prüfe also doppelt, dass der gewählte Ordner nur temporäre Dateien enthält, die jederzeit gelöscht werden können.
Plugins
--------
Aktiviere die folgenden Plugins:
Alternate Pagination
Privacy Image Cache
rendertime
###Alternate Pagination
**Beschreibung**
Dieses Plugin reduziert die Ladezeit der Datenbank massiv. Nachteil: Du kannst nicht mehr die Anzahl aller Seiten sehen.
**Einrichtung**
Gehe auf admin/plugins/altpager und wähle "global".
###Privacy Image Cache
**Beschreibung**
Dieses Plugin lädt externe Inhalte vor und speichert sie im Cache. Neben der Beschleunigung der Seite dient es so außerdem dazu, die Privatssphäre der Nutzer zu schützen, da eingebettete Inhalte so von deiner Seite aus geladen werden und nicht von externen Quellen (die deine IP-Adresse ermitteln könnten).
Ebenso hilft es bei Inhalten, die nur langsam laden oder nicht immer online sind.
**Einrichtung**
Bitte erstelle einen Ordner namens "privacy_image_cache" und "photo" in deinem Stammverzeichnis. Wenn diese Ordner existieren, dann werden die zwischengespeicherten Inhalte dort abgelegt. Dies hat den großen Vorteil, dass der Server die Dateien direkt von dort bezieht.
###rendertime
**Beschreibung**
Dieses Plugin beschleunigt dein System nicht, aber es hilft dabei, die Flaschenhälse zu ermitteln.
Wenn es aktiviert ist, dann siehst du Werte wie die folgenden auf jeder deiner Seiten:
Performance: Database: 0.244, Network: 0.002, Rendering: 0.044, Parser: 0.001, I/O: 0.021, Other: 0.237, Total: 0.548
Database: Dies ist die Zeit für alle Datenbankabfragen
Network: Zeit, die benötigt wird, um Inhalte von externen Seiten vorzuladen
Rendering: Zeit, die zum rendern des Themas benötigt wird
Parser: Die Zeit, die der BBCode-Parser benötigt, um die Ausgabe der Seite zu erstellen
I/O: Zeit, die der lokale Dateizugriff benötigt
Others: alles andere :)
Total: Die Summe aller genannten Werte
Diese Werte zeigen deine Performance-Probleme.
Webserver
----------
Wenn du einen Apache-Webserver nutzt, aktiviere bitte die folgenden Module:
###Cache-Control
**Beschreibung**
Dieses Modul weist den Client an, den Inhalt statischer Dateien zu speichern, um diese nicht immer wieder neu laden zu müssen.
Aktiviere das Modul "mod_expires", indem du "a2enmod expires" als root eingibst.
Füge die folgenden Zeilen in die Apache-Konfiguration deiner Seite im "directory"-Bereich ein.
ExpiresActive on ExpiresDefault "access plus 1 week"
Weitere Informationen findest du hier: http://httpd.apache.org/docs/2.2/mod/mod_expires.html.
###Compress content
**Beschreibung**
Dieses Modul komprimiert den Datenverkehr (Traffic) zwischen dem Webserver und dem Client.
Aktiviere das Modul "mod_deflate" durch die Eingabe "a2enmod deflate" als root.
Weitere Informationen findest du hier: http://httpd.apache.org/docs/2.2/mod/mod_deflate.html
###PHP
**FCGI**
Wenn du Apache nutzt, dann denk darüber nach, FCGI zu nutzen. Wenn du eine Debian-basierte Distribution nutzt, dann wirst du die Pakete "php5-cgi" und "libapache2-mod-fcgid" benötigen.
Nutze externe Dokumente, um eine detailiertere Erklärung für die Einrichtung eines Systems auf FCGI-Basis zu erhalten.
**APC**
APC ist ein Zwischenspeicher für die Verarbeitung des Befehlscodes. Es beschleunigt die Verarbeitung des PHP-Codes.
Wenn APC aktiviert ist, dann nutzt Friendica dies, um Konfigurationseinstellungen für verschiedene Anfragen zwischenzuspeichern. Dies beschleunigt die Reaktionszeit der Seite.
###Database
Es gibt Skripte wie [tuning-primer.sh](http://www.day32.com/MySQL/) und [mysqltuner.pl](http://mysqltuner.pl), die den Datenbankserver analysieren und Hinweise darauf geben, welche Werte verändert werden könnten.
Aktivere hierfür die "Slow query" Log-Datei, um Performanceprobleme zu erkennen.