]> git.mxchange.org Git - friendica.git/blob - doc/Improve-Performance.md
Merge pull request #782 from balderino/master
[friendica.git] / doc / Improve-Performance.md
1 How to: improve performance
2 ==============
3
4 * [Home](help)
5
6 A little guide to increase the performance of a Friendica site
7
8 **At first**
9
10 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.
11
12 System configuration
13 --------
14
15 Please go to /admin/site/ on your system and change the following values:
16
17     Set "JPEG image quality" to 50.
18
19 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.
20
21     Set "OStatus conversation completion interval" to "never".
22
23 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.
24
25     Set "Path for lock file" to an empty folder outside your web root.
26
27 Lock files help avoid the possibility of several background processes running at the same time.
28
29 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.
30
31 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/".
32
33     Enable "Use MySQL full text engine"
34
35 When using MyISAM (default) this speeds up search.
36
37     Set "Path to item cache" to an empty value outside your web root.
38
39 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.
40
41 You can use the same folder you used for the lock file.
42
43 **Warning!**
44
45 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!**
46
47 So double check that the folder only contains temporary content that can be deleted at any time.
48
49 You have been warned.
50
51 P.S. It happened to me :)
52
53 Plugins
54 --------
55
56 Active the following plugins:
57
58     Alternate Pagination
59     Privacy Image Cache
60     rendertime
61
62 ###Alternate Pagination
63
64
65 **Description**
66
67 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.
68
69 **Administration**
70
71 Go to the admin settings of "altpager" and set it to "global".
72
73 ###Privacy Image Cache
74
75 **Description**
76
77 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).
78
79 Additionally it helps with content from external sites that have slow performance or aren not online all the time.
80
81 **Administration**
82
83 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.
84
85
86 ###rendertime
87
88 This plugin doesn't speed up your system. It helps analyzing your bottlenecks.
89
90 When enabled you see some values like the following at the bottom of every page:
91
92     Performance: Database: 0.244, Network: 0.002, Rendering: 0.044, Parser: 0.001, I/O: 0.021, Other: 0.237, Total: 0.548
93
94     Database: This is the time for all database queries
95     Network: Time that is needed to fetch content from external sites
96     Rendering: Time for theme rendering
97     Parser: The time that the BBCode parser needed to create the output
98     I/O: Time for local file access
99     Others: Everything else :)
100     Total: The sum of all above values
101
102 These values show your performance problems.
103
104 Webserver
105 --------
106
107 If you are using Apache please enable the following modules.
108
109 **Cache-Control**
110
111 This module tells the client to cache the content of static files so that they aren't fetched with every request.
112
113 Enable the module "mod_expires" by typing in "a2enmod expires" as root.
114
115 Please add the following lines to your site configuration in the "directory" context.
116
117 ExpiresActive on ExpiresDefault "access plus 1 week"
118
119 See also: http://httpd.apache.org/docs/2.2/mod/mod_expires.html
120
121 **Compress content**
122
123 This module compresses the traffic between the web server and the client.
124
125 Enable the module "mod_deflate" by typing in "a2enmod deflate" as root.
126
127 See also: http://httpd.apache.org/docs/2.2/mod/mod_deflate.html
128
129 PHP
130 --------
131
132 **FCGI**
133
134 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".
135
136 Please refer to external documentations for a more detailed explanation how to set up a system based upon FCGI.
137
138 **APC**
139
140 APC is an opcode cache. It speeds up the processing of PHP code.
141
142 When APC is enabled, Friendica uses it to store configuration data between different requests. This helps speeding up the page creation time.
143
144 **Database**
145
146 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.
147
148 Please enable the slow query log. This helps being aware of performance problems.