changeset 2:781290b4a683

nightly updater. performance config attempts & notes
author drewp@bigasterisk.com
date Fri, 24 Feb 2023 18:31:20 -0800
parents 9dc67ae8b507
children d393292f378c
files .hgignore deploy.yaml skaffold.yaml update.sh update/Dockerfile update/update.sh update_job.yaml
diffstat 7 files changed, 104 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore	Fri Feb 24 18:31:20 2023 -0800
@@ -0,0 +1,1 @@
+photoprism
--- a/deploy.yaml	Sat Jan 14 18:18:35 2023 -0800
+++ b/deploy.yaml	Fri Feb 24 18:31:20 2023 -0800
@@ -60,7 +60,7 @@
       labels:
         app: photoprism
       annotations:
-        prometheus.io/scrape: "false"
+        prometheus.io/port: "9104"
     spec:
       volumes:
         - { name: photoprism-storage, persistentVolumeClaim: { claimName: photoprism-storage } }
@@ -69,14 +69,16 @@
       containers:
         - name: photoprism
           # https://github.com/photoprism/photoprism/releases
-          image: docker.io/photoprism/photoprism:221118-jammy
+          # image: docker.io/photoprism/photoprism:221118-jammy
+          image: docker.io/photoprism/photoprism:preview
           env:
             - { name: PHOTOPRISM_UPLOAD_NSFW, value: "true" }
             - { name: PHOTOPRISM_READONLY, value: "true" }
-            - { name: PHOTOPRISM_LOG_LEVEL, value: "info" }
+            - { name: PHOTOPRISM_LOG_LEVEL, value: "trace" }
+            - { name: PHOTOPRISM_TRACE, value: "true"}
             - { name: PHOTOPRISM_SITE_URL, value: "https://bigasterisk.com/photoprism/" }
             - { name: PHOTOPRISM_AUTH_MODE, value: "public" }
-            - { name: PHOTOPRISM_WORKERS, value: "4" }
+            - { name: PHOTOPRISM_WORKERS, value: "2" }
    
             - { name: PHOTOPRISM_DISABLE_WEBDAV, value: "true" }
             - { name: PHOTOPRISM_DISABLE_CLASSIFICATION, value: "true" }
@@ -90,6 +92,8 @@
             - { name: PHOTOPRISM_DATABASE_USER, value: "photoprism" }
             - { name: PHOTOPRISM_DATABASE_PASSWORD, value: "insecure" }
 
+            - { name: PHOTOPRISM_AUTO_INDEX, value: "-1" }
+            - { name: PHOTOPRISM_AUTO_IMPORT, value: "-1" }
           ports:
             - containerPort: 2342
           volumeMounts:
@@ -101,7 +105,7 @@
               # tensorflow analysis goes to like 1200Mi
               memory: 2500Mi
         - name: mariadb
-          image: docker.io/mariadb:10.10.2
+          image: docker.io/mariadb:10.10.3
           securityContext:
             runAsUser: 1000
             # let https://github.com/MariaDB/mariadb-docker/blob/749c720c63306d1572849afc6ab1cfa02fd08338/10.8/docker-entrypoint.sh 
@@ -109,22 +113,64 @@
           # command: suggested from photoprism docs
           #   - mysqld
           #   - --innodb-buffer-pool-size=512M
+          ## https://mariadb.com/kb/en/set-transaction/#isolation-levels current default is REPEATABLE-READ
           #   - --transaction-isolation=READ-COMMITTED
           #   - --character-set-server=utf8mb4
           #   - --collation-server=utf8mb4_unicode_ci
+          ## default 151
           #   - --max-connections=512
+          ## default 0
           #   - --innodb-rollback-on-timeout=OFF
+          ## default 50
           #   - --innodb-lock-wait-timeout=120
           volumeMounts:
             - { name: photoprism-storage, subPath: "mariadb", mountPath: "/var/lib/mysql" }
             - { name: run-mysqld, mountPath: "/run/mysqld" }
           env:
+          # https://hub.docker.com/_/mariadb/#:~:text=latest%20%2D%2Dverbose%20%2D%2Dhelp-,Environment%20Variables,-When%20you%20start
+          # says these only matter upon the first run.
             - { name: MARIADB_AUTO_UPGRADE, value: "1" }
             - { name: MARIADB_INITDB_SKIP_TZINFO, value: "1" }
             - { name: MARIADB_DATABASE, value: "photoprism" }
             - { name: MARIADB_USER, value: "photoprism" }
             - { name: MARIADB_PASSWORD, value: "insecure" }
             - { name: MARIADB_ROOT_PASSWORD, value: "insecure" }
+        - name: mariadb-exporter
+          # for this to work, run this once:
+          # 
+          # k exec -it deploy/photoprism mariadb -- mysql --user=root --password=insecure
+          # 
+          # CREATE USER 'exporter'@'localhost' IDENTIFIED BY 'XXXXXXXX';
+          # GRANT PROCESS, REPLICATION CLIENT ON *.* TO 'exporter'@'localhost';
+          # GRANT SELECT ON performance_schema.* TO 'exporter'@'localhost';
+          # GRANT ALL ON photoprism.* TO 'exporter'@'localhost';
+          image: prom/mysqld-exporter:v0.14.0
+          args:
+           # see: k exec -it deploy/photoprism -c mariadb-exporter -- /bin/mysqld_exporter --help
+           - "--collect.info_schema.tables.databases=photoprism"
+           - "--collect.info_schema.tables"
+           - "--no-collect.slave_status"
+           - "--collect.info_schema.processlist"
+           - "--no-collect.info_schema.query_response_time"
+           - "--collect.perf_schema.tablelocks"
+           - "--collect.perf_schema.eventsstatements"
+           - "--collect.perf_schema.eventswaits"
+           - "--collect.perf_schema.tableiowaits"
+           - "--collect.perf_schema.indexiowaits"
+           - "--collect.perf_schema.file_events"
+           - "--collect.perf_schema.file_instances"
+           - "--collect.perf_schema.memory_events"
+           # need to turn on 'userstat' in mysql or something for these
+           #- "--collect.info_schema.tablestats"
+           #- "--collect.info_schema.schemastats"
+           - "--log.level=info"
+          ports:
+          - containerPort: 9104
+          env:
+          - name: DATA_SOURCE_NAME
+            value: "exporter:XXXXXXXX@unix(/run/mysqld/mysqld.sock)/"
+          volumeMounts:
+            - { name: run-mysqld, mountPath: "/run/mysqld" }
       affinity:
         nodeAffinity:
           requiredDuringSchedulingIgnoredDuringExecution:
@@ -142,6 +188,7 @@
 spec:
   type: LoadBalancer
   ports:
-    - { port: 80, targetPort: 2342 }
+    - { port: 80, targetPort: 2342, name: web }
+    - { port: 9104, targetPort: 9104, name: metrics }
   selector:
     app: photoprism
--- a/skaffold.yaml	Sat Jan 14 18:18:35 2023 -0800
+++ b/skaffold.yaml	Fri Feb 24 18:31:20 2023 -0800
@@ -1,9 +1,16 @@
-apiVersion: skaffold/v2beta22
+apiVersion: skaffold/v3
 kind: Config
 metadata:
   name: photoprism
+manifests:
+  rawYaml:
+  - deploy.yaml
+  - ingress.yaml
+  - update_job.yaml
 deploy:
-  kubectl:
-    manifests:
-    - deploy.yaml
-    - ingress.yaml
\ No newline at end of file
+  kubectl: {}
+
+build:
+  artifacts:
+    - image: bang5:5000/photoprism_update
+      context: update/
\ No newline at end of file
--- a/update.sh	Sat Jan 14 18:18:35 2023 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-#!/bin/zsh
-
-date
-/my/pda/note10/copy_photos
-
-date
-kubectl exec -it deploy/photoprism -- photoprism index
-
-touch /my/pda/note10/photos_updated
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/update/Dockerfile	Fri Feb 24 18:31:20 2023 -0800
@@ -0,0 +1,5 @@
+FROM bang5:5000/base_basic
+WORKDIR /opt
+COPY update.sh ./
+
+CMD ["./update.sh"]
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/update/update.sh	Fri Feb 24 18:31:20 2023 -0800
@@ -0,0 +1,12 @@
+#!/bin/zsh
+
+date
+/my/pda/note10/copy_photos > /tmp/photo_touched_dirs
+
+date
+
+for x (`cat /tmp/photo_touched_dirs`) {
+  kubectl exec -it deploy/photoprism -c photoprism -- photoprism index $x
+}
+
+touch /my/pda/note10/photos_updated
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/update_job.yaml	Fri Feb 24 18:31:20 2023 -0800
@@ -0,0 +1,21 @@
+apiVersion: batch/v1
+kind: CronJob
+metadata:
+  name: photoprism-update
+spec:
+  schedule: "20 3 * * *"
+  concurrencyPolicy: Replace
+  jobTemplate:
+    spec:
+      template:
+        spec:
+          volumes:
+            - { name: my, persistentVolumeClaim: { claimName: my } }
+          containers:
+          - name: update
+            image: bang5:5000/photoprism_update
+            volumeMounts:
+              - { name: my, mountPath: /my/pic, subPath: pic }
+              - { name: my, mountPath: /my/pda/note10, subPath: pda/note10 }
+          restartPolicy: Never
+      backoffLimit: 1