From f00bfdfe8576236c4e172e44912bcf15744c12bf Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Mon, 25 Feb 2019 14:29:39 +0000 Subject: [PATCH] move slow sms provider threshold from 10% to 20% provider switching is a process that can happen as often as we like without disrupting the flow of the system - however, there are some reasons why we might not want to switch. One problem we've seen is when a provider is having an issue, we might switch away from them manually only for the app to automatically switch back to them again and again. Long term we'd like to have a system better suited for sharing the load equally between our two sms providers, but short term, by increasing the threshold for switching from 10% (of messages sent are slow) to 20%, we hope to make switching happen less often. A notification is considered slow if it was sent in the last ten minutes, on the current provider, and is either * still in sending or pending after 4 minutes * in delivered, but took at least 4 minutes to send --- app/celery/scheduled_tasks.py | 2 +- app/dao/notifications_dao.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/celery/scheduled_tasks.py b/app/celery/scheduled_tasks.py index f8b966e84..04a476378 100644 --- a/app/celery/scheduled_tasks.py +++ b/app/celery/scheduled_tasks.py @@ -106,7 +106,7 @@ def switch_current_sms_provider_on_slow_delivery(): return slow_delivery_notifications = is_delivery_slow_for_provider( provider=current_provider.identifier, - threshold=0.1, + threshold=0.2, created_at=datetime.utcnow() - timedelta(minutes=10), delivery_time=timedelta(minutes=4), ) diff --git a/app/dao/notifications_dao.py b/app/dao/notifications_dao.py index d693bde25..722f03165 100644 --- a/app/dao/notifications_dao.py +++ b/app/dao/notifications_dao.py @@ -494,8 +494,8 @@ def is_delivery_slow_for_provider( slow_notifications = counts.get(True, 0) if total_notifications: - current_app.logger.info("Slow delivery notifications count: {} out of {}. Ratio {}".format( - slow_notifications, total_notifications, slow_notifications / total_notifications + current_app.logger.info("Slow delivery notifications count for provider {}: {} out of {}. Ratio {}".format( + provider, slow_notifications, total_notifications, slow_notifications / total_notifications )) return slow_notifications / total_notifications >= threshold else: