Piwigo with php-fpm for better performance

Hi!
Thanks to your Piwigo docker image I managed to get Piwigo up and running with mariaDB on my Synology DS216+II, which received an upgrade from 1 GB of RAM to 8 GB to be able to handle Piwigo and Nextcloud.

Because I see the same behaviour with 100 % CPU load as in this post I want to use php-fpm but I do not seem to get it right.

My docker-compose.yml for mariaDB and Piwigo:

Use root/example as user/password credentials
version: '3.1'

networks:
  piwigo:
    name: piwigo
    driver: bridge

services:
  db:
     image: mariadb
     container_name: mariadb-piwigo
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: sompass
       MYSQL_DATABASE: piwigo
       MYSQL_USER: someuser
       MYSQL_PASSWORD: somepass
   networks:
       - piwigo
   volumes:
       - /volume1/docker/mariadb:/var/lib/mysql
  
 piwigo:
   image: linuxserver/piwigo
   container_name: piwigo
   restart: unless-stopped
   environment:
     - PUID=1000
     - PGID=1000
     - TZ=Europe/Berlin    
   networks:
     - piwigo   
   volumes:
     - /volume1/docker/piwigo/config:/config    
   ports:
     - 8081:80

Up to this point all is working well, I go through the installation, import some photos and start using Piwigo.

Here is my nginx config:

server {
listen 80;

#listen 443 ssl;

root /config/www/gallery;
index index.html index.htm index.php;

server_name piwigo;

#ssl_certificate /config/keys/cert.crt;
#ssl_certificate_key /config/keys/cert.key;

client_max_body_size 0;

location / {
	try_files $uri $uri/ /index.html /index.php?$args =404;
}

location ~ \.php$ {
	fastcgi_split_path_info ^(.+\.php)(/.+)$;
	# With php5-cgi alone:
	#fastcgi_pass 127.0.0.1:9000;
        fastcgi_pass phpfpm:9000;
	# With php5-fpm:
	#fastcgi_pass unix:/var/run/php7-fpm.sock;
	fastcgi_index index.php;
	include /etc/nginx/fastcgi_params;
}
}

As you can see I even started bitnami/php-fpm as a container and got it sort of working but ran into a couple of write access problems which I tried to resolve like in this post. I’m able to get into the GUI, I can navigate around but pictures are only showing if they have been processed with the standard CGI configuration.

Here is my compose file for php-fpm:

version: "3.5"

networks:
   piwigo:
     name: piwigo
     driver: bridge

services:
   phpfpm:
       image: bitnami/php-fpm
       container_name: phpfpm
   logging:
      driver: json-file
   ports:
      - 9000
  networks:
      - piwigo
  volumes:
      - /volume1/docker/piwigo/config:/config

  restart: unless-stopped

Here an example of one of these errors:

Warning: file_put_contents(./_data/combined/16hsu2w.css): failed to open stream: Permission denied in /config/www/gallery/include/template.class.php on line 1912

And here I lack sufficient knowledge and hope that the community and the developers can help out. I read that it may be a problem with the base image and different UserIDs.

Hi,
I was wondering if manage to get this issue solved of high CPU and Memory usage?
I have just install piwigo (latest) on my DS916+ (8GB RAM) and everything is working okay, but the CPU and Memory usage is constantly high when browsing through the photos via web-interface of mobile apps.

If someone has a suggestion or a fix please don’t be shay :wink: