Skip to content

Commit 74c5e35

Browse files
committed
Limit indexer workers using env var
1 parent aa3a7f5 commit 74c5e35

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

ingestion_server/env.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ RELATIVE_UPSTREAM_DB_PORT="5432"
3535
#SHELF_PATH="/worker_state/db"
3636

3737
#INDEXER_WORKER_HOST="localhost"
38+
#INDEXER_WORKER_LIMIT=""

ingestion_server/ingestion_server/distributed_reindex_scheduler.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424

2525
client = boto3.client("ec2", region_name=config("AWS_REGION", default="us-east-1"))
26+
worker_limit = config("INDEXER_WORKER_LIMIT", default=0, cast=int)
2627

2728

2829
def schedule_distributed_index(db_conn, model_name, table_name, target_index, task_id):
@@ -87,6 +88,13 @@ def _prepare_workers():
8788
servers.append(server)
8889
ids.append(_id)
8990
log.info(f"Selected worker instances {servers}")
91+
92+
if worker_limit > 0:
93+
log.info(f"Truncating worker instances under limit {worker_limit}")
94+
servers = servers[:worker_limit]
95+
ids = ids[:worker_limit]
96+
log.info(f"Truncated worker instances {servers}")
97+
9098
client.start_instances(InstanceIds=ids)
9199
return servers
92100

0 commit comments

Comments
 (0)