[BUG] Performance issues when loading a lot of thumbnails simultaneously in shared albums #837

Closed
opened 2026-02-04 22:54:19 +03:00 by OVERLORD · 6 comments
Owner

Originally created by @JVT038 on GitHub (May 2, 2023).

Originally assigned to: @jrasm91 on GitHub.

The bug

I have a shared album containing ~900 items of images and videos.
When I visit it, it takes a long time to load the thumbnails. Different things happen:

  1. When loading the shared album on my phone in the browser (through a reverse proxy, with incognito mode, without caching stuff), the thumbnails don't load and the following error is spammed in the console:
immich-server_1            | [Nest] 1  - 05/02/2023, 1:14:03 PM   ERROR [ExceptionsHandler] timeout exceeded when trying to connect
immich-server_1            | Error: timeout exceeded when trying to connect
immich-server_1            |     at Timeout._onTimeout (/usr/src/app/node_modules/pg-pool/index.js:200:27)
immich-server_1            |     at listOnTimeout (node:internal/timers:559:17)
immich-server_1            |     at processTimers (node:internal/timers:502:7)
  1. When loading the shared album on my PC (through a reverse proxy, with incognito mode), all the network requests result into http error 429.
    Screenshot:

image

  1. When loading the shared album on my PC without a reverse proxy in incognito mode and without cache, it just takes a long time to load the albums. According to the network panel, 261 requests for thumbnails were sent, 3.33 MB was transferred and this took 2.08 minutes. Additionally, when loading these thumbnails, CPU usage spikes to roughly 25% in my task manager (the service 'node' is probably Immich right?)

The OS that Immich Server is running on

Synology DSM 7.2

Version of Immich Server

v1.54.1

Version of Immich Mobile App

v1.54.0 build.77

Platform with the issue

  • Server
  • Web
  • Mobile

Your docker-compose.yml content

version: "3.8"

networks:
  traefik_proxy:
    external:
      name: traefik_proxy

services:
  immich-server:
    image: ghcr.io/immich-app/immich-server:release
    entrypoint: ["/bin/sh", "./start-server.sh"]
    networks:
      - traefik_proxy
      - default
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
      - sockets:/sockets
    env_file:
      - .env
    environment:
      - NODE_ENV=production
    depends_on:
      - redis
      - database
      - typesense
    restart: always
    labels:
      traefik.enable: "true"
      traefik.docker.network: traefik_proxy
      traefik.http.services.immich-api-svc.loadbalancer.server.port: "3001"
      traefik.http.routers.immich-api-rtr.rule: "Host(`immich.$DOMAINNAME`) && Pathprefix(`/api`)"
      traefik.http.routers.immich-api-rtr.priority: 20
      traefik.http.middlewares.immich-api-strip.stripprefix.prefixes: "/api"
      traefik.http.routers.immich-api-rtr.middlewares: immich-api-strip,chain-basic@file
      traefik.http.routers.immich-api-rtr.service: immich-api-svc
      traefik.http.routers.immich-api-rtr.tls: true
      traefik.http.routers.immich-api-rtr.tls.certresolver: dns-cloudflare
      traefik.http.routers.immich-api-rtr.entrypoints: https

  immich-microservices:
    image: ghcr.io/immich-app/immich-server:release
    entrypoint: ["/bin/sh", "./start-microservices.sh"]
    networks:
      - default
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
      - sockets:/sockets
    env_file:
      - .env
    environment:
      - NODE_ENV=production
    depends_on:
      - redis
      - database
      - typesense
    restart: always

  immich-machine-learning:
    build:
      context: $DOCKERDIR/immich/immich-ml
      dockerfile: Dockerfile
    container_name: immich_machine_learning
    command: [ "python", "src/main.py" ]
    networks:
      - default
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
      - model-cache:/cache
    env_file:
      - .env
    environment:
      - NODE_ENV=production
    restart: always 

  immich-web:
    image: ghcr.io/immich-app/immich-web:release
    entrypoint: ["/bin/sh", "./entrypoint.sh"]
    networks:
      - default
      - traefik_proxy
    env_file:
      - .env
    restart: always
    labels:
      traefik.enable: "true"
      traefik.docker.network: traefik_proxy
      traefik.http.services.immich-svc.loadbalancer.server.port: "3000"
      traefik.http.routers.immich-rtr.rule: "Host(`immich.$DOMAINNAME`)"
      traefik.http.routers.immich-rtr.priority: 10
      traefik.http.routers.immich-rtr.service: immich-svc
      traefik.http.routers.immich-rtr.middlewares: chain-basic@file
      traefik.http.routers.immich-rtr.tls: true
      traefik.http.routers.immich-rtr.tls.certresolver: dns-cloudflare
      traefik.http.routers.immich-rtr.entrypoints: https

  redis:
    container_name: immich_redis
    image: redis:6.2
    restart: always
    networks:
      - default
    command: redis-server /etc/redis.conf
    volumes:
      - sockets:/sockets
      - $DOCKERDIR/immich/redis.conf:/etc/redis.conf
      - /etc/TZ:/etc/timezone:ro
      - $DOCKERDIR/immich/redisdb:/db

  database:
    container_name: immich_postgres
    image: postgres:14-bullseye
    user: 1026:100
    command: postgres -c unix_socket_directories='/var/run/postgresql/,/sockets/'
    env_file:
      - .env
    environment:
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_DB: ${DB_DATABASE_NAME}
      PG_DATA: /var/lib/postgresql/data
      PGPORT: ${DB_PORT}
    volumes:
      - $DOCKERDIR/immich/pgdata:/var/lib/postgresql/data
      - sockets:/sockets
    restart: always

  typesense:
    container_name: immich_typesense
    image: typesense/typesense:0.24.0
    environment:
      - TYPESENSE_API_KEY=${TYPESENSE_API_KEY}
      - TYPESENSE_DATA_DIR=/data
    logging:
      driver: none
    volumes:
      - $DOCKERDIR/immich/typesense:/data

volumes:
  sockets:
    external: true
  model-cache:

Your .env content

DB_HOSTNAME=/sockets
DB_USERNAME=postgres
DB_PASSWORD=postgres
DB_DATABASE_NAME=immich
DB_PORT=5433
REDIS_PASSWORD="secret"
REDIS_SOCKET=/sockets/immich_redis.sock
UPLOAD_LOCATION=/volume1/upload
JWT_SECRET=secret
REVERSE_GEOCODING_PRECISION=3
TYPESENSE_API_KEY=secret

Reproduction steps

1. Create a shared album containing hundreds of items
2. View the shared album through a reverse proxy (Traefik) and see error or view the shared album without a reverse proxy (see the other error) or view the shared album on a smaller viewport (such as a phone) and see the timeout error. Make sure cache is disabled

Additional information

I have connected the postgres and redis servers with unix instead of TCP; I assumed that unix was faster than TCP, but apparently it's not? Or maybe it's not related to postgres and/or redis connections.

Originally created by @JVT038 on GitHub (May 2, 2023). Originally assigned to: @jrasm91 on GitHub. ### The bug I have a shared album containing ~900 items of images and videos. When I visit it, it takes a long time to load the thumbnails. Different things happen: 1. When loading the shared album on my phone in the browser (through a reverse proxy, with incognito mode, without caching stuff), the thumbnails don't load and the following error is spammed in the console: ``` immich-server_1 | [Nest] 1 - 05/02/2023, 1:14:03 PM ERROR [ExceptionsHandler] timeout exceeded when trying to connect immich-server_1 | Error: timeout exceeded when trying to connect immich-server_1 | at Timeout._onTimeout (/usr/src/app/node_modules/pg-pool/index.js:200:27) immich-server_1 | at listOnTimeout (node:internal/timers:559:17) immich-server_1 | at processTimers (node:internal/timers:502:7) ``` 2. When loading the shared album on my PC (through a reverse proxy, with incognito mode), all the network requests result into http error 429. Screenshot: ![image](https://user-images.githubusercontent.com/47184046/235678157-a68ff90c-9b71-4d3c-aad4-66e2d73e0f94.png) 3. When loading the shared album on my PC without a reverse proxy in incognito mode and without cache, it just takes a long time to load the albums. According to the network panel, 261 requests for thumbnails were sent, 3.33 MB was transferred and this took 2.08 minutes. Additionally, when loading these thumbnails, CPU usage spikes to roughly 25% in my task manager (the service 'node' is probably Immich right?) ### The OS that Immich Server is running on Synology DSM 7.2 ### Version of Immich Server v1.54.1 ### Version of Immich Mobile App v1.54.0 build.77 ### Platform with the issue - [X] Server - [X] Web - [ ] Mobile ### Your docker-compose.yml content ```YAML version: "3.8" networks: traefik_proxy: external: name: traefik_proxy services: immich-server: image: ghcr.io/immich-app/immich-server:release entrypoint: ["/bin/sh", "./start-server.sh"] networks: - traefik_proxy - default volumes: - ${UPLOAD_LOCATION}:/usr/src/app/upload - sockets:/sockets env_file: - .env environment: - NODE_ENV=production depends_on: - redis - database - typesense restart: always labels: traefik.enable: "true" traefik.docker.network: traefik_proxy traefik.http.services.immich-api-svc.loadbalancer.server.port: "3001" traefik.http.routers.immich-api-rtr.rule: "Host(`immich.$DOMAINNAME`) && Pathprefix(`/api`)" traefik.http.routers.immich-api-rtr.priority: 20 traefik.http.middlewares.immich-api-strip.stripprefix.prefixes: "/api" traefik.http.routers.immich-api-rtr.middlewares: immich-api-strip,chain-basic@file traefik.http.routers.immich-api-rtr.service: immich-api-svc traefik.http.routers.immich-api-rtr.tls: true traefik.http.routers.immich-api-rtr.tls.certresolver: dns-cloudflare traefik.http.routers.immich-api-rtr.entrypoints: https immich-microservices: image: ghcr.io/immich-app/immich-server:release entrypoint: ["/bin/sh", "./start-microservices.sh"] networks: - default volumes: - ${UPLOAD_LOCATION}:/usr/src/app/upload - sockets:/sockets env_file: - .env environment: - NODE_ENV=production depends_on: - redis - database - typesense restart: always immich-machine-learning: build: context: $DOCKERDIR/immich/immich-ml dockerfile: Dockerfile container_name: immich_machine_learning command: [ "python", "src/main.py" ] networks: - default volumes: - ${UPLOAD_LOCATION}:/usr/src/app/upload - model-cache:/cache env_file: - .env environment: - NODE_ENV=production restart: always immich-web: image: ghcr.io/immich-app/immich-web:release entrypoint: ["/bin/sh", "./entrypoint.sh"] networks: - default - traefik_proxy env_file: - .env restart: always labels: traefik.enable: "true" traefik.docker.network: traefik_proxy traefik.http.services.immich-svc.loadbalancer.server.port: "3000" traefik.http.routers.immich-rtr.rule: "Host(`immich.$DOMAINNAME`)" traefik.http.routers.immich-rtr.priority: 10 traefik.http.routers.immich-rtr.service: immich-svc traefik.http.routers.immich-rtr.middlewares: chain-basic@file traefik.http.routers.immich-rtr.tls: true traefik.http.routers.immich-rtr.tls.certresolver: dns-cloudflare traefik.http.routers.immich-rtr.entrypoints: https redis: container_name: immich_redis image: redis:6.2 restart: always networks: - default command: redis-server /etc/redis.conf volumes: - sockets:/sockets - $DOCKERDIR/immich/redis.conf:/etc/redis.conf - /etc/TZ:/etc/timezone:ro - $DOCKERDIR/immich/redisdb:/db database: container_name: immich_postgres image: postgres:14-bullseye user: 1026:100 command: postgres -c unix_socket_directories='/var/run/postgresql/,/sockets/' env_file: - .env environment: POSTGRES_PASSWORD: ${DB_PASSWORD} POSTGRES_USER: ${DB_USERNAME} POSTGRES_DB: ${DB_DATABASE_NAME} PG_DATA: /var/lib/postgresql/data PGPORT: ${DB_PORT} volumes: - $DOCKERDIR/immich/pgdata:/var/lib/postgresql/data - sockets:/sockets restart: always typesense: container_name: immich_typesense image: typesense/typesense:0.24.0 environment: - TYPESENSE_API_KEY=${TYPESENSE_API_KEY} - TYPESENSE_DATA_DIR=/data logging: driver: none volumes: - $DOCKERDIR/immich/typesense:/data volumes: sockets: external: true model-cache: ``` ### Your .env content ```Shell DB_HOSTNAME=/sockets DB_USERNAME=postgres DB_PASSWORD=postgres DB_DATABASE_NAME=immich DB_PORT=5433 REDIS_PASSWORD="secret" REDIS_SOCKET=/sockets/immich_redis.sock UPLOAD_LOCATION=/volume1/upload JWT_SECRET=secret REVERSE_GEOCODING_PRECISION=3 TYPESENSE_API_KEY=secret ``` ### Reproduction steps ```bash 1. Create a shared album containing hundreds of items 2. View the shared album through a reverse proxy (Traefik) and see error or view the shared album without a reverse proxy (see the other error) or view the shared album on a smaller viewport (such as a phone) and see the timeout error. Make sure cache is disabled ``` ### Additional information I have connected the postgres and redis servers with unix instead of TCP; I assumed that unix was faster than TCP, but apparently it's not? Or maybe it's not related to postgres and/or redis connections.
OVERLORD added the 🖥️web label 2026-02-04 22:54:19 +03:00
Author
Owner

@mjsamberg commented on GitHub (Jul 3, 2023):

I've experienced this issue as well. It's only in shared albums and only not when logged in. The timeline view of my personal photos is super snappy and viewing shared albums while logged in is pretty good too.

I've worked around this by changing my fork to show the newest first in the shared album (which I want to do anyway), but all that means is that the recent stuff can be seen more easily.

@mjsamberg commented on GitHub (Jul 3, 2023): I've experienced this issue as well. It's only in shared albums and only not when logged in. The timeline view of my personal photos is super snappy and viewing shared albums while logged in is pretty good too. I've worked around this by changing my fork to show the newest first in the shared album (which I want to do anyway), but all that means is that the recent stuff can be seen more easily.
Author
Owner

@jrasm91 commented on GitHub (Aug 15, 2023):

Is this issue specifically about sharing/accessing an album via a shared link or via sharing it with another immich user?

@jrasm91 commented on GitHub (Aug 15, 2023): Is this issue specifically about sharing/accessing an album via a shared link or via sharing it with another immich user?
Author
Owner

@mjsamberg commented on GitHub (Aug 16, 2023):

@jrasm91 Shared link. Shared with another immich user works fine, but I have a shared link that I give to family and that's super slow.

@mjsamberg commented on GitHub (Aug 16, 2023): @jrasm91 Shared link. Shared with another immich user works fine, but I have a shared link that I give to family and that's super slow.
Author
Owner

@jrasm91 commented on GitHub (Aug 27, 2023):

Can you retest again @mjsamberg ? I believe this has been fixed in the recent releases.

@jrasm91 commented on GitHub (Aug 27, 2023): Can you retest again @mjsamberg ? I believe this has been fixed in the recent releases.
Author
Owner

@jrasm91 commented on GitHub (Aug 27, 2023):

Fixed in #3776

@jrasm91 commented on GitHub (Aug 27, 2023): Fixed in #3776
Author
Owner

@mjsamberg commented on GitHub (Aug 28, 2023):

Can you retest again @mjsamberg ? I believe this has been fixed in the recent releases.

This has been fixed. Thank you!

@mjsamberg commented on GitHub (Aug 28, 2023): > Can you retest again @mjsamberg ? I believe this has been fixed in the recent releases. This has been fixed. Thank you!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#837