From 1bac8a82a0280cc644cb26e505131071c3892aa1 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Fri, 20 Dec 2024 09:58:03 -0800 Subject: [PATCH 1/3] introduce gaps in message sends --- app/celery/tasks.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/celery/tasks.py b/app/celery/tasks.py index c21f4e65c..77c8fca80 100644 --- a/app/celery/tasks.py +++ b/app/celery/tasks.py @@ -1,4 +1,5 @@ import json +from time import sleep from celery.signals import task_postrun from flask import current_app @@ -75,8 +76,15 @@ def process_job(job_id, sender_id=None): ) ) + # notify-api-1495 we are going to sleep periodically to give other + # jobs running at the same time a chance to get some of their messages + # sent. Sleep for 5 minutes after every 500 sends + count = 0 for row in recipient_csv.get_rows(): process_row(row, template, job, service, sender_id=sender_id) + count = count + 1 + if count % 500 == 0: + sleep(5 * 60) # End point/Exit point for message send flow. job_complete(job, start=start) From 4c5741a82e586b34bded8c19c2cab2114066e100 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Mon, 23 Dec 2024 08:03:12 -0800 Subject: [PATCH 2/3] change timing a bit --- app/celery/tasks.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/celery/tasks.py b/app/celery/tasks.py index 77c8fca80..5122688a9 100644 --- a/app/celery/tasks.py +++ b/app/celery/tasks.py @@ -78,13 +78,14 @@ def process_job(job_id, sender_id=None): # notify-api-1495 we are going to sleep periodically to give other # jobs running at the same time a chance to get some of their messages - # sent. Sleep for 5 minutes after every 500 sends + # sent. Sleep for 40 seconds after every 100 sends, which gives us throughput + # of about 9000 per hour and would keep the queue clear assuming only one sender. count = 0 for row in recipient_csv.get_rows(): process_row(row, template, job, service, sender_id=sender_id) count = count + 1 - if count % 500 == 0: - sleep(5 * 60) + if count % 100 == 0: + sleep(40) # End point/Exit point for message send flow. job_complete(job, start=start) From 85c5268eaedf9c15037ba96baf289f04ee6c16b2 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Mon, 23 Dec 2024 13:51:21 -0800 Subject: [PATCH 3/3] change to send 3 messages per second --- app/celery/tasks.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/celery/tasks.py b/app/celery/tasks.py index 5122688a9..b2ad5abac 100644 --- a/app/celery/tasks.py +++ b/app/celery/tasks.py @@ -78,14 +78,16 @@ def process_job(job_id, sender_id=None): # notify-api-1495 we are going to sleep periodically to give other # jobs running at the same time a chance to get some of their messages - # sent. Sleep for 40 seconds after every 100 sends, which gives us throughput - # of about 9000 per hour and would keep the queue clear assuming only one sender. + # sent. Sleep for 1 second after every 3 sends, which gives us throughput + # of about 3600*3 per hour and would keep the queue clear assuming only one sender. + # It will also hopefully eliminate throttling when we send messages which we are + # currently seeing. count = 0 for row in recipient_csv.get_rows(): process_row(row, template, job, service, sender_id=sender_id) count = count + 1 - if count % 100 == 0: - sleep(40) + if count % 3 == 0: + sleep(1) # End point/Exit point for message send flow. job_complete(job, start=start)