Browse Source

Apache/PHP configuration tweaks

In order to improvee IDP responsiveness
follwing actions were taken:

* updated apache connection settings
* removed access log settings from apache2
* updated php pool settings
* added php.ini settings
** added zend opcode cache
** set php max memory limmit to 32MB
* added php-fpm.conf settings
** set emergency_restart settings

Change-Id: I52aafd41267aa46d4f481b7c91a24732c615632b
Sebastian Marcet 2 years ago
parent
commit
49e222aa4a
6 changed files with 2098 additions and 13 deletions
  1. 2
    0
      files/functions
  2. 129
    0
      files/php-fpm.conf
  3. 1930
    0
      files/php.ini
  4. 10
    5
      files/www.conf
  5. 27
    5
      manifests/init.pp
  6. 0
    3
      templates/vhost.erb

+ 2
- 0
files/functions View File

@@ -242,4 +242,6 @@ function site_update {
242 242
     # activate site
243 243
     rm -rf $SITE_ROOT/w
244 244
     ln -s $target_dir $SITE_ROOT/w
245
+    # to reset op cache
246
+    service php5-fpm restart
245 247
 }

+ 129
- 0
files/php-fpm.conf View File

@@ -0,0 +1,129 @@
1
+;;;;;;;;;;;;;;;;;;;;;
2
+; FPM Configuration ;
3
+;;;;;;;;;;;;;;;;;;;;;
4
+
5
+; All relative paths in this configuration file are relative to PHP's install
6
+; prefix (/usr). This prefix can be dynamically changed by using the
7
+; '-p' argument from the command line.
8
+
9
+; Include one or more files. If glob(3) exists, it is used to include a bunch of
10
+; files from a glob(3) pattern. This directive can be used everywhere in the
11
+; file.
12
+; Relative path can also be used. They will be prefixed by:
13
+;  - the global prefix if it's been set (-p argument)
14
+;  - /usr otherwise
15
+;include=/etc/php5/fpm/*.conf
16
+
17
+;;;;;;;;;;;;;;;;;;
18
+; Global Options ;
19
+;;;;;;;;;;;;;;;;;;
20
+
21
+[global]
22
+; Pid file
23
+; Note: the default prefix is /var
24
+; Default Value: none
25
+pid = /var/run/php5-fpm.pid
26
+
27
+; Error log file
28
+; If it's set to "syslog", log is sent to syslogd instead of being written
29
+; in a local file.
30
+; Note: the default prefix is /var
31
+; Default Value: log/php-fpm.log
32
+error_log = /var/log/php5-fpm.log
33
+
34
+; syslog_facility is used to specify what type of program is logging the
35
+; message. This lets syslogd specify that messages from different facilities
36
+; will be handled differently.
37
+; See syslog(3) for possible values (ex daemon equiv LOG_DAEMON)
38
+; Default Value: daemon
39
+;syslog.facility = daemon
40
+
41
+; syslog_ident is prepended to every message. If you have multiple FPM
42
+; instances running on the same server, you can change the default value
43
+; which must suit common needs.
44
+; Default Value: php-fpm
45
+;syslog.ident = php-fpm
46
+
47
+; Log level
48
+; Possible Values: alert, error, warning, notice, debug
49
+; Default Value: notice
50
+;log_level = notice
51
+
52
+; If this number of child processes exit with SIGSEGV or SIGBUS within the time
53
+; interval set by emergency_restart_interval then FPM will restart. A value
54
+; of '0' means 'Off'.
55
+; Default Value: 0
56
+emergency_restart_threshold = 10
57
+
58
+; Interval of time used by emergency_restart_interval to determine when
59
+; a graceful restart will be initiated.  This can be useful to work around
60
+; accidental corruptions in an accelerator's shared memory.
61
+; Available Units: s(econds), m(inutes), h(ours), or d(ays)
62
+; Default Unit: seconds
63
+; Default Value: 0
64
+emergency_restart_interval = 1m
65
+
66
+; Time limit for child processes to wait for a reaction on signals from master.
67
+; Available units: s(econds), m(inutes), h(ours), or d(ays)
68
+; Default Unit: seconds
69
+; Default Value: 0
70
+process_control_timeout = 10s
71
+
72
+; The maximum number of processes FPM will fork. This has been design to control
73
+; the global number of processes when using dynamic PM within a lot of pools.
74
+; Use it with caution.
75
+; Note: A value of 0 indicates no limit
76
+; Default Value: 0
77
+; process.max = 128
78
+
79
+; Specify the nice(2) priority to apply to the master process (only if set)
80
+; The value can vary from -19 (highest priority) to 20 (lower priority)
81
+; Note: - It will only work if the FPM master process is launched as root
82
+;       - The pool process will inherit the master process priority
83
+;         unless it specified otherwise
84
+; Default Value: no set
85
+; process.priority = -19
86
+
87
+; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging.
88
+; Default Value: yes
89
+;daemonize = yes
90
+
91
+; Set open file descriptor rlimit for the master process.
92
+; Default Value: system defined value
93
+;rlimit_files = 1024
94
+
95
+; Set max core size rlimit for the master process.
96
+; Possible Values: 'unlimited' or an integer greater or equal to 0
97
+; Default Value: system defined value
98
+;rlimit_core = 0
99
+
100
+; Specify the event mechanism FPM will use. The following is available:
101
+; - select     (any POSIX os)
102
+; - poll       (any POSIX os)
103
+; - epoll      (linux >= 2.5.44)
104
+; - kqueue     (FreeBSD >= 4.1, OpenBSD >= 2.9, NetBSD >= 2.0)
105
+; - /dev/poll  (Solaris >= 7)
106
+; - port       (Solaris >= 10)
107
+; Default Value: not set (auto detection)
108
+;events.mechanism = epoll
109
+
110
+; When FPM is build with systemd integration, specify the interval,
111
+; in second, between health report notification to systemd.
112
+; Set to 0 to disable.
113
+; Available Units: s(econds), m(inutes), h(ours)
114
+; Default Unit: seconds
115
+; Default value: 10
116
+;systemd_interval = 10
117
+
118
+;;;;;;;;;;;;;;;;;;;;
119
+; Pool Definitions ;
120
+;;;;;;;;;;;;;;;;;;;;
121
+
122
+; Multiple pools of child processes may be started with different listening
123
+; ports and different management options.  The name of the pool will be
124
+; used in logs and stats. There is no limitation on the number of pools which
125
+; FPM can handle. Your system will tell you anyway :)
126
+
127
+; To configure the pools it is recommended to have one .conf file per
128
+; pool in the following directory:
129
+include=/etc/php5/fpm/pool.d/*.conf

+ 1930
- 0
files/php.ini
File diff suppressed because it is too large
View File


+ 10
- 5
files/www.conf View File

@@ -9,20 +9,25 @@ listen.group = www-data
9 9
 
10 10
 pm = dynamic
11 11
 # the maximum number of children that can be alive at the same time.
12
-pm.max_children = 500
12
+pm.max_children = 800
13 13
 # the number of children created on startup.
14 14
 # pm.start_servers = min_spare_servers + (max_spare_servers - min_spare_servers) / 2
15
-pm.start_servers = 120
15
+pm.start_servers = 300
16 16
 # the minimum number of children in 'idle'
17 17
 # state (waiting to process). If the number
18 18
 # of 'idle' processes is less than this
19 19
 # number then some children will be created.
20
-pm.min_spare_servers = 80
20
+pm.min_spare_servers = 256
21 21
 # the maximum number of children in 'idle'
22 22
 # state (waiting to process). If the number
23 23
 # of 'idle' processes is greater than this
24 24
 # number then some children will be killed.
25
-pm.max_spare_servers = 160
26
-pm.max_requests = 1500
25
+pm.max_spare_servers = 600
26
+pm.max_requests = 5000
27
+
28
+
29
+listen.backlog = -1
30
+request_terminate_timeout = 300s
27 31
 
28 32
 chdir = /
33
+

+ 27
- 5
manifests/init.pp View File

@@ -106,6 +106,30 @@ class openstackid (
106 106
     notify  => Service['php5-fpm'],
107 107
   }
108 108
 
109
+  file { '/etc/php5/fpm/php-fpm.conf':
110
+    ensure  => present,
111
+    owner   => 'root',
112
+    group   => 'www-data',
113
+    mode    => '0640',
114
+    source  => 'puppet:///modules/openstackid/php-fpm.conf',
115
+    require => [
116
+      Package['php5-fpm'],
117
+    ],
118
+    notify  => Service['php5-fpm'],
119
+  }
120
+
121
+  file { '/etc/php5/fpm/php.ini':
122
+    ensure  => present,
123
+    owner   => 'root',
124
+    group   => 'www-data',
125
+    mode    => '0640',
126
+    source  => 'puppet:///modules/openstackid/php.ini',
127
+    require => [
128
+      Package['php5-fpm'],
129
+    ],
130
+    notify  => Service['php5-fpm'],
131
+  }
132
+
109 133
   file { '/etc/php5/fpm/pool.d/www.conf':
110 134
     ensure  => present,
111 135
     owner   => 'root',
@@ -264,12 +288,10 @@ class openstackid (
264 288
 
265 289
   # apache mpm event connection tweaking
266 290
   class {'::apache::mod::event':
267
-    serverlimit         => 128,
291
+    serverlimit         => 16,
268 292
     startservers        => 3,
269
-    minsparethreads     => 96,
270
-    maxsparethreads     => 192,
271
-    threadlimit         => 64,
272
-    threadsperchild     => 32,
293
+    threadlimit         => 256,
294
+    threadsperchild     => 256,
273 295
     maxclients          => 4096,
274 296
     maxrequestsperchild => 5000,
275 297
     maxrequestworkers   => 4096,

+ 0
- 3
templates/vhost.erb View File

@@ -4,8 +4,6 @@
4 4
 
5 5
   ErrorLog ${APACHE_LOG_DIR}/openstackid-error.log
6 6
   LogLevel warn
7
-  CustomLog ${APACHE_LOG_DIR}/openstackid-access.log combined
8
-
9 7
   Redirect / https://<%= scope.lookupvar("openstackid::vhost_name") %>/
10 8
 
11 9
 </VirtualHost>
@@ -17,7 +15,6 @@
17 15
 
18 16
   ErrorLog ${APACHE_LOG_DIR}/openstackid-ssl-error.log
19 17
   LogLevel warn
20
-  CustomLog ${APACHE_LOG_DIR}/openstackid-ssl-access.log combined
21 18
 
22 19
   SSLEngine on
23 20
   SSLProtocol All -SSLv2 -SSLv3

Loading…
Cancel
Save