From df00b7c5e876815aa671ec743a78152251774fb4 Mon Sep 17 00:00:00 2001 From: Edoardo Rosa <6991986+notdodo@users.noreply.github.com> Date: Sun, 22 Sep 2024 00:46:53 +0200 Subject: [PATCH] fix: lambda fine tuning (#19) * fix: lambda fine tuning * fix: lint --- pulumi/__main__.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pulumi/__main__.py b/pulumi/__main__.py index cb443de..73d714c 100644 --- a/pulumi/__main__.py +++ b/pulumi/__main__.py @@ -16,6 +16,9 @@ from telegram_provider import Webhook RESOURCES_PREFIX = "erfiume" +SYNC_MINUTES_RATE_NORMAL = 24 * 60 # Once a day +SYNC_MINUTES_RATE_EMERGENCY = 20 +EMERGENCY = False stazioni_table = dynamodb.Table( f"{RESOURCES_PREFIX}-stazioni", @@ -143,7 +146,8 @@ "ENVIRONMENT": pulumi.get_stack(), }, }, - timeout=60, + memory_size=1024, + timeout=50, ) bot_lambda = lambda_.Function( @@ -160,7 +164,8 @@ "ENVIRONMENT": pulumi.get_stack(), }, }, - timeout=15, + memory_size=1024, + timeout=10, ) scheduler.Schedule( @@ -170,7 +175,7 @@ mode="FLEXIBLE", maximum_window_in_minutes=5, ), - schedule_expression="rate(25 minutes)", + schedule_expression=f"rate({SYNC_MINUTES_RATE_EMERGENCY if EMERGENCY else SYNC_MINUTES_RATE_NORMAL} minutes)", schedule_expression_timezone="Europe/Rome", target=scheduler.ScheduleTargetArgs( arn=fetcher_lambda.arn, @@ -222,13 +227,13 @@ f"{RESOURCES_PREFIX}-fetcher", log_group_class="STANDARD", name="/aws/lambda/erfiume-fetcher", - retention_in_days=60, + retention_in_days=14, ) cloudwatch.LogGroup( f"{RESOURCES_PREFIX}-bot", log_group_class="STANDARD", name="/aws/lambda/erfiume-bot", - retention_in_days=60, + retention_in_days=14, ) if pulumi.get_stack() == "production":