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

Apache + PHP performance tuning #64

Merged
merged 5 commits into from
Nov 18, 2013
Merged

Conversation

EvanK
Copy link
Contributor

@EvanK EvanK commented Nov 13, 2013

Php's memory_limit is calculated in a command task, and the rest are calculated in a template of an apache include (implemented using a custom replace module that's currently a PR for ansible core; see ansible/ansible#4889).

The following global vars can be specified as manual overrides for above calculations:

  • php_settings.memory_limit
  • reserved_memory.mysql
  • reserved_memory.system
  • apache_settings.start_servers
  • apache_settings.min_spare_servers
  • apache_settings.max_spare_servers
  • apache_settings.max_clients
  • apache_settings.max_requests_per_child

Fixes #56

…manual overrides as global vars

* if no manual override, calculating php memory_limit via `shell` task
* replacing apache default prefork config with include to separate file
* generating prefork.conf from template (incl calculated directive values)
* using custom `replace` module, see ansible/ansible#4889

Fixes #56
{% set apache_max_spare_servers = 10 if ansible_memtotal_mb >= 2048 else 3 %}
{%- endif -%}
{%- if apache_max_requests_per_child is undefined -%}
{% set apache_max_requests_per_child = 1000 %}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: as this has little to do with physical machine specs and more to do with bandwidth usage, I figured we can just plug in a sensible default value.

@EvanK
Copy link
Contributor Author

EvanK commented Nov 13, 2013

Confirmed expected behavior for:

Slightly unexpected behavior for:

At a guess, I think there's something off in the php memory_limit calculation. Not a show stopper exactly, but I'd like to get it sorted out before merging

@EvanK
Copy link
Contributor Author

EvanK commented Nov 13, 2013

Fixed for machines with > 2GB

@EvanK
Copy link
Contributor Author

EvanK commented Nov 14, 2013

If there are no objections (pokes @ericclemmons), I'm planning to merge this for 0.2.29

@ericclemmons
Copy link
Contributor

Lots to go over here, but the only potential BC issue I'd have is with variable naming. Would it make sense to have groups, like seen here?

https://github.com/genesis/wordpress/blob/master/provisioning/roles/wordpress/vars/main.yml

@EvanK
Copy link
Contributor Author

EvanK commented Nov 14, 2013

Here's an interesting pitfall: the vars defined in a role (eg, the php_settings.memory_limit in the file linked above) take precedence over the group_vars in $REPO/provisioning/group_vars/webservers.

So yeah...something to be aware of

@EvanK
Copy link
Contributor Author

EvanK commented Nov 14, 2013

Oh, another one! If ansible finds two conflicting groups (python dicts under the hood), it replaces them rather than merging them.

# With this in $REPO/provisioning/group_vars/webservers...
php_settings:
  memory_limit: 320
# And this in $REPO/bower_components/genesis-wordpress/provisioning/roles/wordpress/vars/main.yml...
php_settings:
  date_timezone:  America/Chicago
# We end up losing the nested vars from group_vars. SURPRISE!
php_settings:
  date_timezone:  America/Chicago

…ng settings from roles/wordpress/vars

Note that template logic in prefork.conf is necessarily more complex (as we cannot assign to dicts), but also somewhat more explicit and less magical. I'm okay with this.
@EvanK
Copy link
Contributor Author

EvanK commented Nov 15, 2013

Confirmed expected behavior:

ericclemmons added a commit that referenced this pull request Nov 18, 2013
@ericclemmons ericclemmons merged commit ac25dc7 into master Nov 18, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Apache + PHP memory usage tuning
2 participants