-
Notifications
You must be signed in to change notification settings - Fork 415
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clarify the horizontal scaling documentation
- Loading branch information
Showing
3 changed files
with
119 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
<h4 id="scaling_intro"> | ||
Introduction | ||
<a class="headerlink" href="#scaling_intro" title="Permalink to this headline">¶</a> | ||
</h4> | ||
<p> | ||
The print has a state contains the job queue and each job's state. To enable horizontal scaling, these | ||
states must be persisted. | ||
</p> | ||
<h4 id="scaling_solus"> | ||
Solution | ||
<a class="headerlink" href="#scaling_solus" title="Permalink to this headline">¶</a> | ||
</h4> | ||
<p> | ||
To store the state we use a PostgreSQL database, the database connection should be configured with the | ||
following Java system properties: | ||
</p> | ||
|
||
<ul> | ||
<li><code>db.host</code>: The database server host name</li> | ||
<li><code>db.port</code>: The database server port (defaults to <code>5432</code>)</li> | ||
<li><code>db.username</code>: The username to connect to the database</li> | ||
<li><code>db.password</code>: The password to connect to the database</li> | ||
<li><code>db.name</code>: The name of the database</li> | ||
<li><code>db.schema</code>: The schema to use (defaults to <code>public</code>)</li> | ||
</ul> | ||
|
||
<p> | ||
The schema should exist, and the necessary tables are created automatically (<code>print_accountings</code>, | ||
<code>print_job_results</code>, <code>print_job_statuses</code>). In this mode the container will wait for | ||
the database to be reachable before actually starting the tomcat server. | ||
</p> | ||
|
||
<p>The DB polling can be tuned with these two environment variables:</p> | ||
<ul> | ||
<li> | ||
<code>PRINT_CANCEL_OLD_POLL_INTERVAL</code>: How often in seconds the DB is polled for jobs to be canceled | ||
(default=<code>60</code>s) | ||
</li> | ||
|
||
<li> | ||
<code>PRINT_POLL_INTERVAL</code>: How often in seconds the DB is polled for new jobs | ||
(default=<code>0.5</code>s) | ||
</li> | ||
</ul> | ||
|
||
<h5 id="scaling_docker"> | ||
Docker | ||
<a class="headerlink" href="#scaling_docker" title="Permalink to this headline">¶</a> | ||
</h5> | ||
<p> | ||
On Docker the system properties should be added in the <code>CATALINA_OPTS</code> environment variable Like | ||
that: <code>-D<property name>=<property value></code>. | ||
</p> | ||
|
||
<h5 id="scaling_kubernetes"> | ||
Kubernetes | ||
<a class="headerlink" href="#scaling_kubernetes" title="Permalink to this headline">¶</a> | ||
</h5> | ||
<p>In Kubernetes, you can reuse an environment variable with:</p> | ||
<pre><code> | ||
env: | ||
- name: PROPERTY_VALUE | ||
value: test | ||
- name: CATALINA_OPTS | ||
value: -D<property name>==$(PROPERTY_VALUE) | ||
</code></pre> | ||
|
||
<p>The order is important.</p> | ||
|
||
<p>Full example where we get the database credentials from a secret:</p> | ||
|
||
<pre> | ||
<code> | ||
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) | ||
</code> | ||
</pre> |