Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

Cloudron Forum

Apps | Demo | Docs | Install

Setting memory_limit dynamically in WordPress (Developer) package

Scheduled Pinned Locked Moved WordPress (Developer)
7 Posts 2 Posters 291 Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • d19dotcaD Offline
    d19dotcaD Offline
    d19dotca
    wrote on last edited by d19dotca
    #1

    I've been experimenting the past few months with WP memory limits. I actually just recently found a way to dynamically set it according to the php.ini settings, and it works quite well. I'm curious... can (or should) this be added dynamically to the WordPress package itself to be set this way?

    define( 'WP_MEMORY_LIMIT', ini_get( 'memory_limit' ) );

    We all know the memory limit should generally be greatly increased to at least 128M but usually recommended at 256M for WP_MEMORY_LIMIT so why not just have it set dynamically to the php.ini file / defaults which are higher than the 40M default (which is far too low)?

    This is slightly related to an older post I had actually here for reference: https://forum.cloudron.io/topic/2714/where-is-memory_limit-and-wp_memory_limit-set/5?_=1636224450803 where I asked if this could be done, was told that it always defaults to 40M, but if we add in the line above then that can be fixed to behave in a more recommended manner. I believe the recommendation above is the solution to what you thought was a limitation @girish.

    --
    Dustin Dauncey
    www.d19.ca

    girishG 1 Reply Last reply
    2
  • d19dotcaD d19dotca referenced this topic on
  • girishG Offline
    girishG Offline
    girish Staff
    replied to d19dotca on last edited by girish
    #2

    @d19dotca I think this increases WP default memory limit to 128MB doesn't it? The default Cloudron app container allocation is 256MB and the prefork configuration is setup with 2 server and max 6 iirc. These values are set with the 40MB default in mind.

    In the past, I tried all sorts of things to set the limits based on the container memory limit. But it always fails in some case, so I though it's best to just leave the values as defaults. I think atleast for WP there are gazillion sites saying 40MB is default and how to edit wp-config.php to change it (not sure if this matters).

    d19dotcaD 2 Replies Last reply
    0
  • d19dotcaD Offline
    d19dotcaD Offline
    d19dotca
    replied to girish on last edited by
    #3

    @girish I don't think that's quite correct. In my testing, the default WP memory limit is 40 MB according to the WordPress system info if I don't specify a memory limit in php.ini and don't specify the memory limit in wp-config.php, the 40 MB default is used which is not the recommended setup. This is why I was suggesting the wp-config.php be edited in the package to point to the defaults of php.ini which is the 128 MB you mentioned. Adding that line to the wp-config.php file will automatically make WordPress memory limit match the php.ini setting.

    --
    Dustin Dauncey
    www.d19.ca

    1 Reply Last reply
    0
  • d19dotcaD Offline
    d19dotcaD Offline
    d19dotca
    replied to girish on last edited by d19dotca
    #4

    @girish said in Setting memory_limit dynamically in WordPress (Developer) package:

    setup with 2 server and max 6 iirc

    Just curious where those numbers come from. Here is the mpm_prefork.conf file contents:

    # Restart the app if you make changes to this file
    
    <IfModule mpm_prefork_module>
        # On startup, start these many servers
    	StartServers	2
    
        # At any given time, keep atleast these many servers
    	MinSpareServers	2
    
        # At any given time, keep atmost these many idle servers (this is always >= MinSpareServers+1)
    	MaxSpareServers 3
    
        # Maximum number of servers at any given instant. Requests will be queued after this
    	MaxRequestWorkers	  15
    
        # Recycle process after handling these many requests. This protected against accidental memory leaks
    	MaxConnectionsPerChild   100
    </IfModule>
    

    I think this means we can have a minimum of 2 Apache server processes and a maximum of 15.

    --
    Dustin Dauncey
    www.d19.ca

    girishG 1 Reply Last reply
    0
  • girishG Offline
    girishG Offline
    girish Staff
    replied to d19dotca on last edited by
    #5

    @d19dotca indeed. looks like the managed version has slightly different values - https://git.cloudron.io/cloudron/wordpress-managed-app/-/blob/master/apache/mpm_prefork.conf (don't think it's intentional that they are different).

    <IfModule mpm_prefork_module>
        # On startup, start these many servers
    	StartServers	2
    
        # At any given time, keep atleast these many servers
    	MinSpareServers	2
    
        # At any given time, keep atmost these many idle servers (this is always >= MinSpareServers+1)
    	MaxSpareServers 3
    
        # Maximum number of servers at any given instant. Requests will be queued after this
    	MaxRequestWorkers	  6
    
        # Recycle process after handling these many requests. This protected against accidental memory leaks
    	MaxConnectionsPerChild   100
    </IfModule>
    
    
    1 Reply Last reply
    0
  • d19dotcaD Offline
    d19dotcaD Offline
    d19dotca
    wrote on last edited by
    #6

    @girish did you mean to duplicate your post? lol. Not sure if you meant to provide a different update or not.

    --
    Dustin Dauncey
    www.d19.ca

    girishG 1 Reply Last reply
    0
  • girishG Offline
    girishG Offline
    girish Staff
    replied to d19dotca on last edited by
    #7

    @d19dotca whoops, looks like some network retry from my browser. did not notice! i removed the dup.

    1 Reply Last reply
    0

  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
  • Login

  • Don't have an account? Register

  • Login or register to search.