memory consumption on multiple wordpress instance

May 26, 2016 1.4k views
WordPress Server Optimization LEMP Ubuntu 16.04

i want to know, if i install multiple wordpress instance through nginx virtual hosts, will they consume ram individually? or PHP will consume as 1 instance?

for example 4 virtual host - Plain HTML - wordpress - wordpress - PHP based application

3 out of 4 required PHP. so the PHP consumption will be like 1 central instance or each will eat RAM separately?

also is there any way to have and on single wordpress install?

1 Answer

You can do it both ways, where by you have a dedicated instance for each site that uses PHP or one master PHP that spawns children. In your case you are looking to conserve memory usage so you want to have one master process that spawns children as necessary.

The way you define that is by setting each one of your php-fpm pools to be ondemand

pm = ondemand
pm.max_children = 5
pm.process_idle_timeout = 10s
pm.max_requests = 200

This will given you one process and spawn as necessary. This will also limit the maximum number of children to 5 and will leave each one spawned for 10 seconds before killing it so that it can serve other requests. Each process will also be terminated when they have either been idle for 10 seconds or if they have processed 200 requests and you can change these variables based on your memory consumption.

The drawback to this is that you will have an initial lag when the first process needs to be spawned, but it doesn't seem like you are worried about that in this case.

If you want to host the same blog from multiple subdomains you can just set that up in Nginx config:

  • @moisey
    thank you so much. really appreciate your help.

    now would you tell me how can i have a wordpress blog like ( where is a simple HTML site.

    thanks in advance again.

    • In most cases if you setup your virtual host the right way you can just create a directory called blog/ in your web root and put your blog there while all of your other content can reside inside of the regular web root directory and then you will be able to browse as your main site, and as your blog.

Have another answer? Share your knowledge.