Skip to content

Commit

Permalink
[celery] No over parallelism
Browse files Browse the repository at this point in the history
Making part of the process synchronous (parallelize ony by schedd) will create less and small messages,  and with a small number of workers will have a better performance.
  • Loading branch information
cronosnull committed Jun 4, 2020
1 parent 6ca7af9 commit 83516ca
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ services:
restart: 'no'
environment: *env
# entrypoint: ["python","/cms-htcondor-es/tests/celery_test.py"]
entrypoint: ["python","/cms-htcondor-es/celery_spider_cms.py","--feed_es","--query_queue_batch_size","5000"]
entrypoint: ["python","/cms-htcondor-es/celery_spider_cms.py","--feed_es","--query_queue_batch_size","1000", "--amq_bunch_size", "500"]
depends_on:
- spider-worker

Expand Down
4 changes: 3 additions & 1 deletion k8s/cronjobs/spider-cron-queues.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ spec:
- /cms-htcondor-es/celery_spider_cms.py
- --feed_es
- --query_queue_batch_size
- "5000"
- "500"
- --amq_bunch_size
- "500"
env: &spider_env
- name: AFFILIATION_DIR_LOCATION
value: /cms_shared/affiliation_dir.json
Expand Down
2 changes: 1 addition & 1 deletion k8s/deployments/spider-flower.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ spec:
resources:
requests:
cpu: 100m
memory: 500Mi
memory: 100Mi
limits:
cpu: 300m
memory: 1Gi
Expand Down
6 changes: 3 additions & 3 deletions k8s/deployments/spider-redis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ spec:
- containerPort: 6379
resources:
requests:
cpu: 200m
memory: 4Gi
cpu: 150m
memory: 2Gi
limits:
cpu: 500m
memory: 8Gi
memory: 4Gi
volumeMounts:
- mountPath: /data
name: redis-claim0
Expand Down
2 changes: 1 addition & 1 deletion k8s/deployments/spider-worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ spec:
- "celery,es_post,convert"
resources:
requests:
cpu: 600m
cpu: 300m
memory: 500Mi
limits:
cpu: 1000m
Expand Down
12 changes: 6 additions & 6 deletions src/htcondor_es/celery/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def grouper(iterable, n, fillvalue=None):
"""
# grouper('ABCDEFG', 3, 'x') --> ABC DEF Gxx"
args = [iter(iterable)] * n
return filter(None, zip_longest(*args, fillvalue=fillvalue))
return zip_longest(*args, fillvalue=fillvalue)


def consume(iterator, n=None):
Expand Down Expand Up @@ -266,8 +266,8 @@ def send_data(
responses = []
total_tasks = 0
for docs_bunch in grouper(query_iter, bunch):
process_and_send = group(
process_docs.si(
process_and_send = [
process_docs(
list(filter(None, X)),
reduce_data=not keep_full_queue_data,
pool_name=pool_name,
Expand All @@ -276,9 +276,9 @@ def send_data(
metadata=metadata,
)
for X in grouper(docs_bunch, chunk_size)
)
total_tasks += len(process_and_send.tasks)
responses.append(process_and_send.apply_async(serializer="pickle"))
]
total_tasks += len(filter(None,docs_bunch))
#responses.append(process_and_send.apply_async(serializer="pickle"))
return total_tasks


Expand Down

0 comments on commit 83516ca

Please sign in to comment.