Unnecessary statistics requests made when viewing a person #6973

Closed
opened 2026-02-05 12:41:22 +03:00 by OVERLORD · 0 comments
Owner

Originally created by @kliberty on GitHub (Aug 25, 2025).

I have searched the existing issues, both open and closed, to make sure this is not a duplicate report.

  • Yes

The bug

When opening a person in the web client two identical requests are made to /api/people/{UUID}/statistics. The second request is not started until the first succeeds. For an person with a large number of images, these requests are fairly expensive (~500ms for 2k images for me).

Image

When viewing a person, if you open an image and press left or right on the keyboard these two requests are repeated. The image renders prior to the requests finishing, so it does not impede "slow browsing" behavior", but if you repeatedly press left or right to jump forward several images, it won't advance to the next image until the statistics requests finish for each one.

In this screenshot I cleared the request history and then pressed "right" on the keyboard once.
Image

The statistics requests when viewing a slide show seem unnecessary to me since the actual counter can't be seen.

Workaround

Using an nginx/openresty reverse proxy we can inspect the $http_referer variable to determine that the photo is open in the viewer and skip proxying the request to the backend. I'm sure this could be handled better with caching, but as a quick work around it hasn't caused me any problems.

location ~ /api/people/.+?/statistics {
    if ($http_referer ~* ^[^?]+/photos/) {
        return 200 '{}';
    }
    proxy_http_version 1.1;
    proxy_set_header   "Connection" "";
    proxy_pass http://immich_backend;
}

The OS that Immich Server is running on

openSUSE 15.6 (docker 25.0.6-ce)

Version of Immich Server

v1.139.2

Version of Immich Mobile App

v1.139.2

Platform with the issue

  • Server
  • Web
  • Mobile

Device make and model

No response

Your docker-compose.yml content

(default with the following changes)

 # The compose file on main may not be compatible with the latest release.

-name: immich
+name: immich-old

 services:
   immich-server:
-    container_name: immich_server
     image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
     # extends:
     #   file: hwaccel.transcoding.yml
     #   service: cpu # set to one of [nvenc, quicksync, rkmpp, vaapi, vaapi-wsl] for accelerated transcoding
     volumes:
       # Do not edit the next line. If you want to change the media storage location on your system, edit the value of UPLOAD_LOCATION in the .env file
-      - ${UPLOAD_LOCATION}:/data
+      - ${UPLOAD_LOCATION}:/usr/src/app/upload
       - /etc/localtime:/etc/localtime:ro
+      - ./remote:/mnt/remote:ro
+      - ./remote-other:/mnt/remote-other:ro
     env_file:
       - .env
     ports:
-      - '2283:2283'
+      - '2284:2283'
     depends_on:
       - redis
       - database
-    restart: always
+    restart: no
     healthcheck:
       disable: false

   immich-machine-learning:
-    container_name: immich_machine_learning
     # For hardware acceleration, add one of -[armnn, cuda, rocm, openvino, rknn] to the image tag.
     # Example tag: ${IMMICH_VERSION:-release}-cuda
     image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}
@@ -43,19 +47,21 @@
       - model-cache:/cache
     env_file:
       - .env
-    restart: always
+    restart: no
+    #ports:
+    #  - 3003:3003
     healthcheck:
       disable: false

   redis:
-    container_name: immich_redis
     image: docker.io/valkey/valkey:8-bookworm@sha256:a137a2b60aca1a75130022d6bb96af423fefae4eb55faf395732db3544803280
     healthcheck:
       test: redis-cli ping || exit 1
-    restart: always
+    restart: no

   database:
-    container_name: immich_postgres
     image: ghcr.io/immich-app/postgres:14-vectorchord0.4.3-pgvectors0.2.0@sha256:32324a2f41df5de9efe1af166b7008c3f55646f8d0e00d9550c16c9822366b4a
     environment:
       POSTGRES_PASSWORD: ${DB_PASSWORD}
@@ -63,7 +69,9 @@
       POSTGRES_DB: ${DB_DATABASE_NAME}
       POSTGRES_INITDB_ARGS: '--data-checksums'
       # Uncomment the DB_STORAGE_TYPE: 'HDD' var if your database isn't stored on SSDs
-      # DB_STORAGE_TYPE: 'HDD'
+      DB_STORAGE_TYPE: 'HDD'
+    ports:
+      - 5433:5432
     volumes:
       # Do not edit the next line. If you want to change the database storage location on your system, edit the value of DB_DATA_LOCATION in the .env file
       - ${DB_DATA_LOCATION}:/var/lib/postgresql/data

Your .env content

(default)

Reproduction steps

  1. Open a person in the web viewer.
  2. Click a photo.
  3. Press next/prev image.
    ...

Relevant log output


Additional information

No response

Originally created by @kliberty on GitHub (Aug 25, 2025). ### I have searched the existing issues, both open and closed, to make sure this is not a duplicate report. - [x] Yes ### The bug When opening a person in the web client two identical requests are made to `/api/people/{UUID}/statistics`. The second request is not started until the first succeeds. For an person with a large number of images, these requests are fairly expensive (~500ms for 2k images for me). <img width="3820" height="1032" alt="Image" src="https://github.com/user-attachments/assets/0ec48208-b689-4dd1-96a4-22a3aaaa6095" /> When viewing a person, if you open an image and press left or right on the keyboard these two requests are repeated. The image renders prior to the requests finishing, so it does not impede "slow browsing" behavior", but if you repeatedly press left or right to jump forward several images, it won't advance to the next image until the statistics requests finish for each one. In this screenshot I cleared the request history and then pressed "right" on the keyboard once. <img width="3840" height="1010" alt="Image" src="https://github.com/user-attachments/assets/9cb7aefa-9593-4763-a05e-0eafeae439e6" /> The statistics requests when viewing a slide show seem unnecessary to me since the actual counter can't be seen. ## Workaround Using an nginx/openresty reverse proxy we can inspect the `$http_referer` variable to determine that the photo is open in the viewer and skip proxying the request to the backend. I'm sure this could be handled better with caching, but as a quick work around it hasn't caused me any problems. ```nginx location ~ /api/people/.+?/statistics { if ($http_referer ~* ^[^?]+/photos/) { return 200 '{}'; } proxy_http_version 1.1; proxy_set_header "Connection" ""; proxy_pass http://immich_backend; } ``` ### The OS that Immich Server is running on openSUSE 15.6 (docker 25.0.6-ce) ### Version of Immich Server v1.139.2 ### Version of Immich Mobile App v1.139.2 ### Platform with the issue - [ ] Server - [x] Web - [ ] Mobile ### Device make and model _No response_ ### Your docker-compose.yml content ```YAML (default with the following changes) # The compose file on main may not be compatible with the latest release. -name: immich +name: immich-old services: immich-server: - container_name: immich_server image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release} # extends: # file: hwaccel.transcoding.yml # service: cpu # set to one of [nvenc, quicksync, rkmpp, vaapi, vaapi-wsl] for accelerated transcoding volumes: # Do not edit the next line. If you want to change the media storage location on your system, edit the value of UPLOAD_LOCATION in the .env file - - ${UPLOAD_LOCATION}:/data + - ${UPLOAD_LOCATION}:/usr/src/app/upload - /etc/localtime:/etc/localtime:ro + - ./remote:/mnt/remote:ro + - ./remote-other:/mnt/remote-other:ro env_file: - .env ports: - - '2283:2283' + - '2284:2283' depends_on: - redis - database - restart: always + restart: no healthcheck: disable: false immich-machine-learning: - container_name: immich_machine_learning # For hardware acceleration, add one of -[armnn, cuda, rocm, openvino, rknn] to the image tag. # Example tag: ${IMMICH_VERSION:-release}-cuda image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release} @@ -43,19 +47,21 @@ - model-cache:/cache env_file: - .env - restart: always + restart: no + #ports: + # - 3003:3003 healthcheck: disable: false redis: - container_name: immich_redis image: docker.io/valkey/valkey:8-bookworm@sha256:a137a2b60aca1a75130022d6bb96af423fefae4eb55faf395732db3544803280 healthcheck: test: redis-cli ping || exit 1 - restart: always + restart: no database: - container_name: immich_postgres image: ghcr.io/immich-app/postgres:14-vectorchord0.4.3-pgvectors0.2.0@sha256:32324a2f41df5de9efe1af166b7008c3f55646f8d0e00d9550c16c9822366b4a environment: POSTGRES_PASSWORD: ${DB_PASSWORD} @@ -63,7 +69,9 @@ POSTGRES_DB: ${DB_DATABASE_NAME} POSTGRES_INITDB_ARGS: '--data-checksums' # Uncomment the DB_STORAGE_TYPE: 'HDD' var if your database isn't stored on SSDs - # DB_STORAGE_TYPE: 'HDD' + DB_STORAGE_TYPE: 'HDD' + ports: + - 5433:5432 volumes: # Do not edit the next line. If you want to change the database storage location on your system, edit the value of DB_DATA_LOCATION in the .env file - ${DB_DATA_LOCATION}:/var/lib/postgresql/data ``` ### Your .env content ```Shell (default) ``` ### Reproduction steps 1. Open a person in the web viewer. 2. Click a photo. 3. Press next/prev image. ... ### Relevant log output ```shell ``` ### Additional information _No response_
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#6973