From 4dced587ad5404d0083e7a4e2353c205b04acdc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Thu, 6 Jul 2023 09:26:25 +0200 Subject: [PATCH] Clarify the horizontal scaling documentation --- docs/src/main/resources/templates/_main.html | 4 + docs/src/main/resources/templates/docker.html | 45 ------- .../src/main/resources/templates/scaling.html | 115 ++++++++++++++++++ 3 files changed, 119 insertions(+), 45 deletions(-) create mode 100644 docs/src/main/resources/templates/scaling.html diff --git a/docs/src/main/resources/templates/_main.html b/docs/src/main/resources/templates/_main.html index 465eeb71a6..86b5587e7f 100644 --- a/docs/src/main/resources/templates/_main.html +++ b/docs/src/main/resources/templates/_main.html @@ -93,6 +93,10 @@
  • Docker
  • + +
  • + Horizontal scaling +
  • diff --git a/docs/src/main/resources/templates/docker.html b/docs/src/main/resources/templates/docker.html index 5360fa4fc0..c616772cb7 100644 --- a/docs/src/main/resources/templates/docker.html +++ b/docs/src/main/resources/templates/docker.html @@ -104,48 +104,3 @@

    Other parameters are documented here: https://docs.sentry.io/clients/java/config/

    - -

    - Multi-instance - -

    - -

    - In this mode several instances of the print will collaborate together to handle the print jobs. The state is - stored in a database. You need to add the following parameters to CATALINA_OPTS: -

    - - -

    Example:

    - -
    
    -docker run --name=mapfish-print-test --publish=8080:8080
    ---env=TOMCAT_LOG_TYPE=json
    ---env=CATALINA_OPTS="-Ddb.name=mydb -Ddb.host=myserver -Ddb.username=myuser -Ddb.password=mypwd -Ddb.port=5432"
    -mydockerhub/mapfish-print:latest
    -
    - -

    - The necessary tables are created automatically (print_accountings, print_job_results, print_job_statuses). - In this mode the container will wait for the database to be reachable before actually starting the tomcat - server. -

    - -

    The DB polling can be tuned with those two environment variables:

    - diff --git a/docs/src/main/resources/templates/scaling.html b/docs/src/main/resources/templates/scaling.html new file mode 100644 index 0000000000..07f6bb5b4d --- /dev/null +++ b/docs/src/main/resources/templates/scaling.html @@ -0,0 +1,115 @@ +

    + Introduction + +

    +

    + The print has a state containing the job queue and each job's state. To enable horizontal scaling, these + states must be persisted. +

    +

    + Solution + +

    +

    + To store the state we use a PostgreSQL database, the database connection should be configured with the + following Java system properties: +

    + + + +

    + The schema should exist, and the necessary tables are created automatically (print_accountings, + print_job_results, print_job_statuses). In this mode, the container will wait for + the database to be reachable before actually starting the tomcat server. +

    + +

    The DB polling can be tuned with these two environment variables:

    + + +
    + Docker + +
    +

    + In a Docker environment, the system properties should be added in the CATALINA_OPTS environment + variable Like that: -D<property name>=<property value>. +

    + +
    + Kubernetes + +
    +

    In Kubernetes, you can reuse an environment variable with:

    +
    
    +  env:
    +    - name: PROPERTY_VALUE
    +      value: test
    +    - name: CATALINA_OPTS
    +      value: -D<property name>==$(PROPERTY_VALUE)
    +
    + +

    The order is important.

    + +

    Full example where we get the database credentials from a secret:

    + +
    +  
    +env:
    +  - name: PGHOST
    +    valueFrom:
    +      secretKeyRef:
    +        key: hostname
    +        name: database-credential-secret
    +  - name: PGPORT
    +    valueFrom:
    +      secretKeyRef:
    +        key: port
    +        name: database-credential-secret
    +  - name: PGUSER
    +    valueFrom:
    +      secretKeyRef:
    +        key: username
    +        name: database-credential-secret
    +  - name: PGPASSWORD
    +    valueFrom:
    +      secretKeyRef:
    +        key: password
    +        name: database-credential-secret
    +  - name: PGDATABASE
    +    valueFrom:
    +      secretKeyRef:
    +        key: database
    +        name: database-credential-secret
    +  - name: PGSCHEMA
    +    value: print
    +  - name: PGOPTIONS
    +    value: '-c statement_timeout=30000'
    +  - name: PRINT_POLL_INTERVAL
    +    value: '1'
    +  - name: CATALINA_OPTS
    +    value: >-
    +      -Ddb.host=$(PGHOST)
    +      -Ddb.port=$(PGPORT)
    +      -Ddb.username=$(PGUSER)
    +      -Ddb.password=$(PGPASSWORD)
    +      -Ddb.name=$(PGDATABASE)
    +      -Ddb.schema=$(PGSCHEMA)
    +
    +