Charts: [bitnami/wordpress]: Uses a lot of RAM

Created on 31 Mar 2020  Â·  18Comments  Â·  Source: bitnami/charts

kc top pods

automatic-solutions   automatic-solutions-7f5b58d565-4xttm                         30m          345Mi
automatic-solutions   automatic-solutions-change-solution-pages-5bff97586c-mxcmw   4m           244Mi
automatic-solutions   automatic-solutions-dev-6c699b95fc-f2tw6                     3m           321Mi
automatic-solutions   automatic-solutions-feature-b9c5b9bcd-vm5cb                  23m          232Mi
automatic-solutions   automatic-solutions-layout-update-7d547976d8-cwdwr           13m          186Mi
highseason            highseason-5c58d6595f-qtlbz                                  12m          261Mi
highseason            highseason-dev-6d85fc9cc-srhnb                               12m          292Mi
highseason            highseason-develop-6ddb8d8c49-m4dxk                          7m           246Mi
highseason            highseason-styles-f4c48dc74-7cw4h                            3m           217Mi

My custom docker image use only 50mb of RAM ()

bug stale

All 18 comments

Hi @polRk

We're currently working on releasing the new version of WordPress: 5.4.0. This new version will include important improvements in the memory usage.

I'll keep you updated once the new version is released so you can give it a try and evaluate its performance.

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

Hi @polRk

Sorry I forgot to notify you about the version 5.4.0 being released. Could you give it a try?

$ helm install wordpress bitnami/wordpress
$ kubectl top pods
NAME                         CPU(cores)   MEMORY(bytes)
wordpress-779547c4ff-gz6cs   5m           84Mi
wordpress-mariadb-0          5m           75Mi
NAME                                        NAMESPACE           REVISION    UPDATED                                 STATUS      CHART           APP VERSION
automatic-solutions                         automatic-solutions 3           2020-04-17 09:02:05.471905638 +0000 UTC deployed    wordpress-9.1.8 5.4.0
automatic-solutions-change-solution-pages   automatic-solutions 1           2020-03-31 12:04:43.68204307 +0000 UTC  deployed    wordpress-9.1.1 5.3.2
automatic-solutions-dev                     automatic-solutions 40          2020-04-17 10:56:16.970489175 +0000 UTC deployed    wordpress-9.1.8 5.4.0
automatic-solutions-feature                 automatic-solutions 1           2020-03-31 11:45:21.148157985 +0000 UTC deployed    wordpress-9.1.1 5.3.2
automatic-solutions-fix-style               automatic-solutions 1           2020-04-14 07:02:22.810550174 +0000 UTC deployed    wordpress-9.1.4 5.4.0
automatic-solutions-fix-style-dev           automatic-solutions 1           2020-04-13 20:25:56.168421104 +0000 UTC deployed    wordpress-9.1.4 5.4.0
automatic-solutions-fix-styles              automatic-solutions 2           2020-04-13 20:06:55.464980529 +0000 UTC deployed    wordpress-9.1.4 5.4.0
automatic-solutions-layout-update           automatic-solutions 1           2020-03-31 14:07:37.879268567 +0000 UTC deployed    wordpress-9.1.1 5.3.2
automatic-solutions-ostrodev                automatic-solutions 1           2020-04-02 11:37:48.046412537 +0000 UTC deployed    wordpress-9.1.1 5.3.2
➜  ~ kc top pods -n automatic-solutions
NAME                                                         CPU(cores)   MEMORY(bytes)
automatic-solutions-898998756-vp6wv                          1m           150Mi
automatic-solutions-change-solution-pages-5bff97586c-mxcmw   5m           281Mi
automatic-solutions-dev-785f74978b-rdjww                     1m           125Mi
automatic-solutions-feature-b9c5b9bcd-vm5cb                  8m           265Mi
automatic-solutions-fix-style-646b6f7848-dv4cb               1m           112Mi
automatic-solutions-fix-style-dev-5947fdfb86-86drr           1m           105Mi
automatic-solutions-fix-styles-54b575fb87-wftg2              1m           41Mi
automatic-solutions-layout-update-7d547976d8-cwdwr           13m          255Mi
automatic-solutions-ostrodev-66658c9fcb-2sv86                8m           286Mi

Hi @polRk

As you can see, the ones using WordPress 5.4.0 consume between 140 to 150 Mi, while the ones using the previous version 5.3.2 consume more than 250 Mi. It's a very significant improvement.

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

150 Mi is a lot. Free load instance should take ~ 50 Mi

That's true @polRk . Indeed I installed the chart from scratch and it's consuming ~80Mi:

$ helm install wordpress bitnami/wordpress
$ kubectl top pods
NAME                        CPU(cores)   MEMORY(bytes)
wordpress-d8d895969-btt98   4m           84Mi
wordpress-mariadb-0         3m           74Mi

Could you connect to your WordPress container and run the command below? Please share the output then.

ps -o pid,user,%mem,command ax | sort -b -k3 -r

@juan131 Sorry, now i'm using my custom docker image.

bash-5.0# ps -o pid,comm,time,rss
PID   COMMAND          TIME  RSS
    1 supervisord       0:14  17m
    7 nginx             0:00 3384
    8 php-fpm7          0:03  15m
    9 nginx             0:06 2624
  568 php-fpm7          0:24  21m
  634 php-fpm7          0:12  16m
  649 bash              0:00 2156
  671 ps                0:00    4

And kc top

NAME                                                 CPU(cores)   MEMORY(bytes)
automatic-solutions-7b78576f7c-qmt8m                 10m          56Mi
automatic-solutions-asw-17-759846cc9-scrxz           95m          78Mi
automatic-solutions-asw-87-658d7bc565-rlrnc          51m          80Mi
automatic-solutions-cf7-messenger-6b49c68476-m9zlb   69m          81Mi

For kubernetes i should split nginx and php-fpm containers in pod. These are plans for the future

And bitnami/wordpress

➜  automatic-solutions git:(styles-asw-89) kc get pods -n test
NAME                         READY   STATUS    RESTARTS   AGE
wordpress-54b6db9586-njnbm   1/1     Running   0          3m52s
wordpress-mariadb-0          1/1     Running   0          3m52s
➜  automatic-solutions git:(styles-asw-89) kc top pods -n test
NAME                         CPU(cores)   MEMORY(bytes)
wordpress-54b6db9586-njnbm   6m           107Mi
wordpress-mariadb-0          4m           80Mi

And

   75 1001      1.6 httpd -f /opt/bitnami/apache/conf/httpd.conf -DFOREGROUND
   76 1001      1.5 httpd -f /opt/bitnami/apache/conf/httpd.conf -DFOREGROUND
   83 1001      1.3 httpd -f /opt/bitnami/apache/conf/httpd.conf -DFOREGROUND
   82 1001      1.3 httpd -f /opt/bitnami/apache/conf/httpd.conf -DFOREGROUND
   80 1001      1.3 httpd -f /opt/bitnami/apache/conf/httpd.conf -DFOREGROUND
   79 1001      1.3 httpd -f /opt/bitnami/apache/conf/httpd.conf -DFOREGROUND
   78 1001      1.3 httpd -f /opt/bitnami/apache/conf/httpd.conf -DFOREGROUND
   77 1001      1.3 httpd -f /opt/bitnami/apache/conf/httpd.conf -DFOREGROUND
   74 1001      1.3 httpd -f /opt/bitnami/apache/conf/httpd.conf -DFOREGROUND
    1 1001      0.0 tini -- httpd -f /opt/bitnami/apache/conf/httpd.conf -DFOREG
   88 1001      0.0 ps -o pid,user,%mem,command ax
  PID USER     %MEM COMMAND

Hi @polRk

It looks it's just a matter of how many processes you set in the php-fpm configuration. You're also using NGINX (instead of Apache).

We also provide a WP image that uses NGINX instead of Apache (see https://github.com/bitnami/bitnami-docker-wordpress-nginx)

$ helm install wordpress bitnami/wordpress --set image.repository=bitnami/wordpress-nginx --set image.tag=5.4.1-debian-10-r10
$ kubectl top pods
NAME                         CPU(cores)   MEMORY(bytes)
wordpress-66dc54d6bc-pnsdm   542m         37Mi
wordpress-mariadb-0          30m          74Mi
$ kubectl exec -it wordpress-66dc54d6bc-pnsdm bash
I have no name!@wordpress-66dc54d6bc-pnsdm:/$ ps -o pid,user,%mem,command ax | sort -b -k3 -r
     90 1001      0.4 php-fpm: master process (/opt/bitnami/php/etc/php-fpm.conf)
      1 1001      0.0 tini -- /run.sh
    100 1001      0.0 sort -b -k3 -r
     99 1001      0.0 ps -o pid,user,%mem,command ax
     92 1001      0.0 nginx: worker process
     91 1001      0.0 nginx: worker process
     87 1001      0.0 nginx: master process nginx -c /opt/bitnami/nginx/conf/nginx.conf -g daemon off;
     93 1001      0.0 bash
    PID USER     %MEM COMMAND

@juan131 Thank you!
The only problem why I don't use your helm package is the long installation, startup, and the docker image is not immutable, which is very important when developing in github

@juan131 Where i can reed about nami, packages and how you create docker images ? I want to create a immutable docker image and helm package for your company and me.

The main goal will be to quickly create builds, light weight, low memory consumption, and immutability of wp-content (except for the uploads folder, it will be volume). There will be two versions (production and development ). All security rights will be disabled in development and you will not be allowed to write to the uploads folder

Hi @polRk

We cannot create "inmutable" versions of these images since we're developing them flexible enough to cover as many use cases as possible. To do so, we need to add logic that, based on environment variables, configure WordPress one way or another during the 1st boot.

That said, it's great if you're working on an "inmutable" version based on the Bitnami WordPress.

You can lean more about Nami in the repository below:

I am afraid that we don't have the "nami modules", the ones downloaded using "bitnami-pkg" in the Dockerfile below, on any public repository.

However, you can use a small trick to download them and take a look to the logic. Based on the "bitnami-pkg" commands available in the Dockerfile, you can download them to inspect them locally using the command below:

$ curl -LOf https://downloads.bitnami.com/files/stacksmith/XXX-A.B.C-Y-linux-amd64-debian-10.tar.gz

For example:

$ curl -LOf https://downloads.bitnami.com/files/stacksmith/wordpress-5.4.1-2-linux-amd64-debian-10.tar.gz

A good starting point to create an "inmutable" image would be applying the changes below in the Dockerfile and the entrypoint:

  • Dockerfile:
  RUN bitnami-pkg install php-7.4.5-1 ...
- RUN bitnami-pkg unpack apache-2.4.43-1 ...
+ RUN bitnami-pkg install apache-2.4.43-1 ...
  RUN bitnami-pkg install wp-cli-2.4.0-0 ...
- RUN bitnami-pkg unpack mysql-client-10.3.22-1 ...
+ RUN bitnami-pkg install mysql-client-10.3.22-1 ...
  RUN bitnami-pkg install libphp-7.4.5-0 ...
- RUN bitnami-pkg unpack wordpress-5.4.1-2 ...
+ RUN bitnami-pkg install wordpress-5.4.1-2 ...
  RUN bitnami-pkg install tini-0.19.0-0 ...
  RUN bitnami-pkg install gosu-1.12.0-0 ...
  • Entrypoint:
  print_welcome_page

- if [[ "$1" == "nami" && "$2" == "start" ]] || [[ "$1" == "httpd" ]]; then
-     . /apache-init.sh
-     . /wordpress-init.sh
-     nami_initialize apache mysql-client wordpress
-     info "Starting gosu... "
-    . /post-init.sh
- fi

  exec tini -- "$@"

With these changes, basically, you're saying: "do not install WP, Apache, etc. during the 1st boot... Do it during build time instead"

@juan131 Thank you! After I create image, how can I offer it to you ?

Hi @polRk

Once you have your solution ready, please feel free to share it with us so we can review what you did. You can create a PR for instance, adding your proposal for a "immutable WordPress".

We cannot publish a "third-party" image in our publishing channels, for security reasons, but we are glad to check your code and provide you feedback.

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

Was this page helpful?
0 / 5 - 0 ratings