Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding server tuning adjustments for MariaDB and PHP FPM #1430

Closed
wants to merge 1 commit into from

Conversation

paulbrzeski
Copy link
Contributor

@paulbrzeski paulbrzeski commented Oct 7, 2022

Closed and superceded by service specific PRs:

Sharing a couple of changes we've made to our Trellis so we can fine tune MariaDB and PHP settings for high traffic websites.

Changes include,

  • MariaDB/innodb optimisation
  • PHP-FPM crash prevention and optimisation
  • Small improvements to make things more semantic
  • Various configs to support above

This PR only provides the defaults, you can override these settings like any other using your group_vars configs.

Example settings from our production servers below,

MariaDB for a server with 4GB of RAM and sharing environment with PHP and Nginx
New variables to add to group_vars/%ENV%/mariadb.yml,

mariadb_set_innodb_buffer_pool_size: true
mariadb_innodb_buffer_pool_size: 512M
mariadb_set_innodb_log_file_size: true
mariadb_innodb_log_file_size: 128M

More info - https://mariadb.com/kb/en/innodb-system-variables/#innodb_buffer_pool_size

PHP FPM for a server sharing environment with MariaDB.
New variables to add to group_vars/%ENV%/php.yml,

# Allow a max of 100 children, based on 16GB of ram and 164mb per child.
php_fpm_pm_max_children: 100
# Start and go up in small incremenets as we have the CPU to spare.
php_fpm_pm_start_servers: 5
php_fpm_pm_min_spare_servers: 5
php_fpm_pm_max_spare_servers: 35
# Allow lots of requests as we have the resources to spare.
php_fpm_pm_max_requests: 1000

# Emergency restart settings.
# Restart after 60 seconds if 10 PHP instances have not responded for 5 min

# Number of child processes not responding
php_fpm_set_emergency_restart_threshold: true
php_fpm_emergency_restart_threshold: 10

# Length of time children not responding.
php_fpm_set_emergency_restart_interval: true
php_fpm_emergency_restart_interval: 5m

# Time to wait before restarting after interval passes.
php_fpm_set_process_control_timeout: true
php_fpm_process_control_timeout: 60s

More info - https://geekflare.com/php-fpm-optimization/

@swalkinshaw
Copy link
Member

Thanks @paulbrzeski. There's some good stuff in here we should add. Do you want to do two PRs to separate the mariadb and php parts?

@paulbrzeski
Copy link
Contributor Author

No worries @swalkinshaw :)

That's done,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants