kristophjunge / docker-mediawiki

Dockerized MediaWiki running under Nginx and PHP-FPM. Based on the official PHP7 image. Packaged with VisualEditor plugin and Parsoid service.
MIT License
62 stars 41 forks source link

Memory usage #8

Closed Cypris2010 closed 6 years ago

Cypris2010 commented 7 years ago

Short question: How much memory does the the container use in average. I extended the image with composer und the chameloen skin and now it uses about 380 MB of RAM.

Have you encountered similar numbers?

toak commented 7 years ago

My container uses between 430 - 700 MB

herrmanthegerman commented 6 years ago

I'm running this container on a Synology NAS and just after installation the Synology Web GUI states a memory allocation of about 500 MBytes of RAM.

kristophjunge commented 6 years ago

In the initial container version i used the default performance settings for Nginx, PHP-FPM and Parsoid. While Nginx and PHP-FPM have dynamic management of worker processes, Parsoid can only manage a static number of workers.

However the default settings that were used were targeting more high availability setups. Since for such setups i recommend manually tweaking and mounting the configuration files, i decided to setup the default values for a minimal usage like in a NAS.

As result i introduced the new environment variables PHPFPM_WORKERS_START, PHPFPM_WORKERS_MIN,PHPFPM_WORKERS_MAX and MEDIAWIKI_PARSOID_WORKERS.

The default number of PHP-FPM worker processes that will initially be startet was reduced from 10 to 1. The default number of Parsoid worker processes that will initially be startet was reduced from 6 to 1.

This reduces the number of processes in the container and therefor affects the memory usage when idle or in low usage.

Top before

top - 13:32:11 up  1:06,  0 users,  load average: 1.78, 1.42, 1.09
Tasks:  24 total,   1 running,  23 sleeping,   0 stopped,   0 zombie
%Cpu(s): 13.5 us, 11.5 sy,  0.0 ni, 74.8 id,  0.1 wa,  0.0 hi,  0.1 si,  0.0 st
KiB Mem:  12210672 total, 11920212 used,   290460 free,  1286668 buffers
KiB Swap: 12494844 total,        0 used, 12494844 free.  4043868 cached Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND     
    1 root      20   0   20080   2892   2604 S   0.0  0.0   0:00.02 docker-ent+ 
   14 root      20   0   55244  15244   6484 S   0.0  0.1   0:00.08 supervisord 
   17 root      20   0   21700   5824   3292 S   0.0  0.0   0:00.01 python      
   18 root      20   0   91348   8460   7104 S   0.0  0.1   0:00.00 nginx       
   19 root      20   0  249424  24728  18044 S   0.0  0.2   0:00.02 php-fpm     
   20 parsoid   20   0  946716  50280  14916 S   0.0  0.4   0:00.64 nodejs      
   26 www-data  20   0   91796   3728   2128 S   0.0  0.0   0:00.00 nginx       
   27 www-data  20   0  249424   8996   2312 S   0.0  0.1   0:00.00 php-fpm     
   28 www-data  20   0  249424   9000   2316 S   0.0  0.1   0:00.00 php-fpm     
   29 www-data  20   0  249424   9000   2316 S   0.0  0.1   0:00.00 php-fpm     
   30 www-data  20   0  249424   9004   2320 S   0.0  0.1   0:00.00 php-fpm     
   31 www-data  20   0  249424   9004   2320 S   0.0  0.1   0:00.00 php-fpm     
   32 www-data  20   0  249424   9004   2320 S   0.0  0.1   0:00.00 php-fpm     
   33 www-data  20   0  249424   9004   2320 S   0.0  0.1   0:00.00 php-fpm     
   34 www-data  20   0  249424   9004   2320 S   0.0  0.1   0:00.00 php-fpm     
   35 www-data  20   0  249424   9008   2320 S   0.0  0.1   0:00.00 php-fpm     
   36 www-data  20   0  249424   9008   2320 S   0.0  0.1   0:00.00 php-fpm 

Please note that the Parsoid workers are not visible here because they run in the master process.

Docker stats before

CONTAINER ID        NAME                CPU %               MEM USAGE / LIMIT     MEM %               NET I/O             BLOCK I/O           PIDS
a360b7bc032c        wiki                0.21%               589.1MiB / 11.65GiB   4.94%               1.43MB / 345kB      0B / 24.6kB         86

Top after

top - 13:28:16 up  1:02,  0 users,  load average: 1.17, 1.20, 0.95
Tasks:  11 total,   1 running,  10 sleeping,   0 stopped,   0 zombie
%Cpu(s):  4.5 us,  1.9 sy,  0.0 ni, 93.5 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem:  12210672 total, 11298328 used,   912344 free,  1275648 buffers
KiB Swap: 12494844 total,        0 used, 12494844 free.  3874872 cached Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                  
    1 root      20   0   20080   2872   2588 S   0.0  0.0   0:00.02 docker-entrypoi                                                                                          
   14 root      20   0   55244  15224   6464 S   0.0  0.1   0:00.08 supervisord                                                                                              
   17 root      20   0   21700   5776   3244 S   0.0  0.0   0:00.00 python                                                                                                   
   18 root      20   0   91348   8364   7008 S   0.0  0.1   0:00.00 nginx                                                                                                    
   19 root      20   0  249424  24024  17344 S   0.0  0.2   0:00.02 php-fpm                                                                                                  
   20 parsoid   20   0  946276  47604  14888 S   0.0  0.4   0:00.61 nodejs                                                                                                   
   26 www-data  20   0   91924   6024   4152 S   0.0  0.0   0:00.01 nginx                                                                                                    
   27 www-data  20   0  267752  37500  14560 S   0.0  0.3   0:00.85 php-fpm                                                                                                  
   32 parsoid   20   0 1101204  92052  14804 S   0.0  0.8   0:01.40 node                                                                                                     
   42 root      20   0   21932   2272   1944 R   0.0  0.0   0:00.02 top                                                                                                      
   48 www-data  20   0  256912  23008  11436 S   0.0  0.2   0:00.21 php-fpm 

Docker stats after

CONTAINER ID        NAME                CPU %               MEM USAGE / LIMIT     MEM %               NET I/O             BLOCK I/O           PIDS
dff901930e64        wiki                0.03%               164.1MiB / 11.65GiB   1.38%               1.42MB / 350kB      3.41MB / 24.6kB     28

For more information look at the new section "Performance" in README.md.