Skip to content

Commit 682f524

Browse files
apognuPascal-Delange
authored andcommitted
Run Yente with workers and indexer on the side. Document how to increase tunables for Yente.
1 parent 3a5cb4e commit 682f524

File tree

3 files changed

+35
-9
lines changed

3 files changed

+35
-9
lines changed

.env.example

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# REQUIRED SETTINGS
33
#
44

5-
# If equal to "development", applies configurations on the backend and frontend containers that
5+
# If equal to "development", applies configurations on the backend and frontend containers that
66
# are not suitable for production, related to CORS, secure cookies and https.
77
# Any other value works for a production environment, and will be used by sentry to mark the environment
88
# an error occurred in.
@@ -32,10 +32,10 @@ MARBLE_API_URL_CLIENT="http://localhost:8080"
3232
# RSA private key, in PEM format, used for for signing authentication tokens. MUST be changed for production.
3333
# We recommend using AUTHENTICATION_JWT_SIGNING_KEY_FILE to point to a private key on disk because multi-line
3434
# environment variables are not handled very gracefully.
35-
#
35+
#
3636
# If using AUTHENTICATION_JWT_SIGNING_KEY, line breaks should be replaced with '\n':
3737
# e.g. AUTHENTICATION_JWT_SIGNING_KEY="-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBA...
38-
#
38+
#
3939
# To generate a private key, use `openssl genrsa -out /path/to/private/key.pem 4096`.
4040
# If left empty, a key will be regenerated on every app restart, which may cause unexpected logouts.
4141
AUTHENTICATION_JWT_SIGNING_KEY=
@@ -81,7 +81,7 @@ INGESTION_BUCKET_URL="file://./tempFiles/data-ingestion-bucket?create_dir=true"
8181
CASE_MANAGER_BUCKET_URL="file://./tempFiles/case-manager-bucket?create_dir=true"
8282

8383
# Configure your Firebase project to allow username and password authentication.
84-
# To retrieve this value, go into the settings of your Firebase project, and register
84+
# To retrieve this value, go into the settings of your Firebase project, and register
8585
# a new app from the 'General' tab.
8686
FIREBASE_API_KEY=
8787

@@ -105,7 +105,7 @@ CREATE_ORG_ADMIN_EMAIL=
105105

106106
# Configure the connection details to your Metabase instance.
107107
# - To retrieve the JWT signing key, go to your Metabase admin panel, in 'Settings', then 'Embedding', and click 'Manage' under 'Static embedding'
108-
# - The dashboard ID is the ID of the dashboard you want to embed in Marble. You will find it when you publish a dashboard as
108+
# - The dashboard ID is the ID of the dashboard you want to embed in Marble. You will find it when you publish a dashboard as
109109
# a static embedding on Metabase.
110110
# - The site url can be on a metabase domain, or can use your self-hosted Metabase instance.
111111
METABASE_SITE_URL=
@@ -115,7 +115,7 @@ METABASE_GLOBAL_DASHBOARD_ID=
115115
# Set up connection details to Convoy to enable webhooks sending.
116116
# You can get your project ID and API key from your project settings page in Convoy's dashboard, in the "Secrets" section.
117117
# NB: CONVOY_API_URL should be {scheme}://{host}:{port}/api - forgetting the /api will result in unexpected errors.
118-
CONVOY_API_URL=
118+
CONVOY_API_URL=
119119
CONVOY_API_KEY=
120120
CONVOY_PROJECT_ID=
121121

@@ -124,6 +124,8 @@ CONVOY_PROJECT_ID=
124124
# when using docker-compose.
125125
YENTE_ELASTICSEARCH_URL=http://marble-es:9200
126126
YENTE_PORT=8000
127+
YENTE_API_WORKERS=4
128+
YENTE_QUERY_CONCURRENCY=50
127129
ES_PORT=9200
128130

129131
# Configure access to the Open Sanctions API to use sanction checks
@@ -141,6 +143,6 @@ SENTRY_DSN=
141143

142144
# If you need to support federated authentication through Firebase, you will need to configure the following settings:
143145
# To retrieve those values, go into the settings of your Firebase project, and register a new app from the 'General' tab.
144-
# The two pieces of information below will be provided to you after that.
146+
# The two pieces of information below will be provided to you after that.
145147
# FIREBASE_APP_ID=
146148
# FIREBASE_AUTH_DOMAIN=

docker-compose.yaml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,34 @@ services:
160160
- marble-es:/usr/share/elasticsearch/data
161161
yente:
162162
container_name: marble-yente
163-
image: ghcr.io/opensanctions/yente:4.2.1
163+
image: ghcr.io/opensanctions/yente:4.2.3
164164
depends_on:
165165
- elasticsearch
166+
command:
167+
[
168+
"uvicorn",
169+
"--host=0.0.0.0",
170+
"--workers=${YENTE_API_WORKERS:-4}",
171+
"yente.asgi:app",
172+
]
166173
ports:
167174
- ${YENTE_PORT:-8000}:${YENTE_PORT:-8000}
168175
environment:
169176
YENTE_INDEX_TYPE: elasticsearch
170-
YENTE_INDEX_URL: "${YENTE_ELASTICSEARCH_URL}"
177+
YENTE_INDEX_URL: ${YENTE_ELASTICSEARCH_HOST:-http://marble-es:9200}
178+
YENTE_QUERY_CONCURRENCY: ${YENTE_QUERY_CONCURRENCY:-50}
179+
YENTE_UPDATE_TOKEN: ""
180+
YENTE_AUTO_REINDEX: false
181+
yente-indexer:
182+
container_name: marble-yente-indexer
183+
image: ghcr.io/opensanctions/yente:4.2.3
184+
depends_on:
185+
- elasticsearch
186+
command: ["yente", "reindex"]
187+
environment:
188+
YENTE_INDEX_TYPE: elasticsearch
189+
YENTE_INDEX_URL: ${YENTE_ELASTICSEARCH_HOST:-http://marble-es:9200}
190+
YENTE_QUERY_CONCURRENCY: "50"
171191
YENTE_UPDATE_TOKEN: ""
172192

173193
volumes:

installation/production_run.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ Options:
131131

132132
> ⚠️ **Note**: While development docker-compose includes Elasticsearch, use a production-grade service for deployment.
133133
134+
It is recommended to deploy the Yente API with multiple workers (see the `docker-compose.yaml` to see how) and disable the indexing process on those with `YENTE_AUTO_REINDEX=false`) so it doesn't impact production workloads and is not duplicated across workers.
135+
136+
Once automatic background indexing is disabled, you will need to run it (with `yente reindex`) separately through a different container or a scheduled task (cron or systemd timer).
137+
134138
## Deployment Architecture
135139

136140
### Components

0 commit comments

Comments
 (0)