Skip to content

Apache + PHP memory usage tuning #56

Closed

Description

@EvanK

Though I don't know yet how we'll implement this, we'd like to — as part of the provisioning process — calculate a php memory_limit and several apache directives, based on the server's total RAM capacity.

Our target machine for a genesis install would have 2GB or more, while the local vagrant machine currently is allocated 1GB.

Note: I'm assuming #53 would mean Vagrant's memory usage would be negligible and roll into the overall system reserved memory.

First, we should calculate memory set aside for specific non-apache uses. I'm thinking the following:

  • System reserved memory: 512M for a machine with 2G or more, otherwise 1/4 of total system memory
  • MySQL reserved memory: 512M for a machine with 2G or more, otherwise 320M
  • PHP memory_limit: 256M for a machine with 2G or more, otherwise 128M

And apache-specific settings:

  • StartServers: 5 for a machine with 2G or more, otherwise 2
  • MinSpareServers: 5 for a machine with 2G or more, otherwise 2
  • MaxSpareServers: 10 for a machine with 2G or more, otherwise 3
  • MaxRequestsPerChild: Pulling a figure out of thin air, but I'm thinking 5000 should work?
  • MaxClients: the greater of these two:
    • ($TotalMemory - $ReservedSystemMemory - $ReservedMysqlMemory) / $PhpMemoryLimit
    • The number of vcpus the machine has

Thoughts?

Activity

  1. EvanK commented on Nov 8, 2013

    @EvanK
    ContributorAuthor

    Since the php memory limit is an upper limit and applies to each individual apache child process, we could probably safely halve it for the MaxClients calculation

  2. EvanK commented on Nov 8, 2013

    @EvanK
    ContributorAuthor
  3. danieljgraves commented on Nov 8, 2013

    @danieljgraves

    Good work. I agree!

  4. epitty1023 commented on Nov 8, 2013

    @epitty1023

    MaxRequestsPerChild
    5000 should work well when using 16Gb of ram, I would divide that number when scaling down memory
    16Gb - 5000
    8Gb - 2500
    4Gb - 1250
    2Gb - 1000 ( I know is not 625 but the number works well on this one too , I've tested it)

    what we don't want to do is leave it at 0 (default values) I have read that 0 tends to keep the Max Request in memory causing memory leaks in application and crashing apache, from note on the internet

  5. added a commit that references this issue on Nov 13, 2013
    0ee021f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions