{"id":15528480,"url":"https://github.com/satyamsoni2211/lambdawarmerpy","last_synced_at":"2026-02-18T04:37:35.389Z","repository":{"id":40249403,"uuid":"493233403","full_name":"satyamsoni2211/LambdaWarmerPy","owner":"satyamsoni2211","description":"Python Utility package to warm up Lambda instances to overcome cold start issue. https://pypi.org/project/py-lambda-warmer/","archived":false,"fork":false,"pushed_at":"2022-12-09T06:43:32.000Z","size":58,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-16T17:42:36.653Z","etag":null,"topics":["aws","aws-lambda","aws-sam","lambda-function","lambda-functions","lambda-warmer","lambdas","py-lambda-warmer","python3","sam","serverless","serverless-application-model","serverless-architectures","warming"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/satyamsoni2211.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-17T12:05:17.000Z","updated_at":"2023-11-11T04:51:56.000Z","dependencies_parsed_at":"2023-01-25T17:01:35.641Z","dependency_job_id":null,"html_url":"https://github.com/satyamsoni2211/LambdaWarmerPy","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satyamsoni2211%2FLambdaWarmerPy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satyamsoni2211%2FLambdaWarmerPy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satyamsoni2211%2FLambdaWarmerPy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satyamsoni2211%2FLambdaWarmerPy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/satyamsoni2211","download_url":"https://codeload.github.com/satyamsoni2211/LambdaWarmerPy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247544687,"owners_count":20956031,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","aws-lambda","aws-sam","lambda-function","lambda-functions","lambda-warmer","lambdas","py-lambda-warmer","python3","sam","serverless","serverless-application-model","serverless-architectures","warming"],"created_at":"2024-10-02T11:13:53.625Z","updated_at":"2025-10-08T18:54:21.740Z","avatar_url":"https://github.com/satyamsoni2211.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"This is a utility project designed to cater neccessities for warming up `Lambda` functions to prevent cold starts.\n\n## Table Of Contents\n\n- [Table Of Contents](#table-of-contents)\n- [Installing Warmer](#installing-warmer)\n- [Using Warmer](#using-warmer)\n- [Setting up Event Bridge Notifications](#setting-up-event-bridge-notifications)\n- [Working on enhancements](#working-on-enhancements)\n\n#\n\n[![upload-artifacts-and-release-new-version](https://github.com/satyamsoni2211/LambdaWarmerPy/actions/workflows/release.yaml/badge.svg)](https://github.com/satyamsoni2211/LambdaWarmerPy/actions/workflows/release.yaml) [![PyPI version](https://badge.fury.io/py/py-lambda-warmer.svg)](https://badge.fury.io/py/py-lambda-warmer)\n\n\u003ca name=\"installing-warmer\"\u003e\u003c/a\u003e\n\n## Installing Warmer\n\nTo install module, run the below command:\n\n```bash\npython3 -m pip install py_lambda_warmer\n\n# or\n\npython3 -m pip install py_lambda_warmer==\u003crelease-version\u003e\n```\n\n\u003e This does not specify `boto3` library as hard core requirements while installing as it expects \n\u003e lambda environment to already have it in order *to reduce the layer size* created. This would not be the case with development. You will have to explicitely  install dependencies using `dev_requirements.txt` file.\n\u003e ( Changes made since release 0.1.5 )`\n\n\n\u003ca name=\"using-warmer\"\u003e\u003c/a\u003e\n\n## Using Warmer\n\nThis is very easy to incorporate in your existing Python Lambda Handlers. Follow the below code.\n\n```python\nfrom warmer import warmer\n@warmer(flag=\"custom_event_key\", _concurrency=1)\ndef handler(event, context):\n    pass\n```\n\n\u003e Parameters:\n\u003e *flag* (type: str)- name of the event flag to look for \n\u003e *_concurrency* (type: int)- (optional) Number of concurrent handlers to warm up, default: 1\n\n\nIf your handler is a Flask/FastApi application, you may follow below steps:\n\n```python\nfrom warmer import warmer\nfrom flask import Flask\napp = Flask()\n@warmer(flag=\"custom_event_key\",_concurrency=1)\ndef application(event, context):\n    return app(event, context)\n\n# or\n\napplication = warmer(flag=\"custom_event_key\",_concurrency=1)(app)\n\n# you may now use application as your handler\n```\n\n\u003e `warmer` will help you cater the custom events that are coming for warming _Lambda_ function.\n\u003e Though `_concurrency` is optional and by default it only warms up current execution. In case you want to warm up multiple instances of lambda handler, you may need to adjust `_concurrency` to *number of handlers running*.\n\n\u003e `Warmer` uses threading mechnism to ensure that the warming calls are actually happening concurrently and not serially.\n\n\u003ca name=\"setting-up-event-bridge-notifications\"\u003e\u003c/a\u003e\n\n## Setting up Event Bridge Notifications\n\nYou can also setup you custom event bridge schedule for Lambda function using the `Terraform Resource` code mentioned in\nthe repository.\n\nSimply download the `Terraform` code attached in the release and unzip it.\n\n\u003e \u003cspan style=\"color:red;font-size:large\"\u003eNote:\u003c/span\u003e Make sure your function execution role has required permission to invoke your `Lambda` function else concurrent call executions might fail.\n\n```bash\nwget https://github.com/satyamsoni2211/LambdaWarmerPy/releases/download/${release}/terraform_code.zip\nunzip terraform_code.zip -d terraform_code/\ncd terraform_code/\n# creating variable file required by terraform\ncat \u003c\u003c EOF \u003e .auto.tfvars\narn = \u003carn of your lambda function\u003e\nprofile = \u003cprofile alias for aws\u003e\nregion = \u003cregion for aws lambda\u003e\nEOF\n# initiating and applying\nterraform init\nterraform plan -out tfplan\nterraform apply tfplan\n```\n\nYou may also modify resource names as per your requirements in the code.\n\nYou may also use `AWS SAM` template to create `Event Bridge Notifications` to warm up `Lambda` function.\n\n```yaml\nTransactionCompsAPI:\n  Type: \"AWS::Serverless::Function\"\n  Properties:\n    FunctionName: fake-function\n    Policies:\n        - LambdaInvokePolicy:\n            FunctionName: \"fake-function\"\n    Events:\n      WarmerSchedule: # add this event to the same template\n        Type: Schedule\n        Properties:\n          Schedule: cron(*/5 * ? * 2-6 *)\n          Name: fake-function-warmer-event\n          Description: Warmer Event for Lambda Function\n          Enabled: true\n          Input: '{\"warmer\": true}' # this refers to the warmer flag\n```\n\nIn case you want to include concurrent executions, you may add below to include concurrent invocations.\n\n\u003e \u003cspan style=\"color:red;font-size:large\"\u003eNote:\u003c/span\u003e Using concurrency would also require you to add sufficient permissions to the role to call `lambda:invokeFunction` action on the `Lambda` function. Below code snippet includes policy to grant action to the role.\n\n```yaml\nTransactionCompsAPI:\n  Type: \"AWS::Serverless::Function\"\n  Properties:\n    FunctionName: fake-function\n    Policies:\n        - LambdaInvokePolicy:\n            FunctionName: \"fake-function\"\n    Events:\n      WarmerSchedule: # add this event to the same template\n        Type: Schedule\n        Properties:\n          Schedule: cron(*/5 * ? * 2-6 *)\n          Name: fake-function-warmer-event\n          Description: Warmer Event for Lambda Function\n          Enabled: true\n          Input: '{\"warmer\": true, \"concurrency\": 5}' # this refers to the warmer flag and concurrency\n```\n\n\u003ca name=\"working-on-enhancements\"\u003e\u003c/a\u003e\n## Working on enhancements\n\nIf you want to work on enhancements or development, you may clone the project and run the below commands to setup environment:\n\n```bash\npython -m pip install pipenv\npipenv shell\n\n# or\n\npython -m pip install virtualenv\nvirtualenv venv\nsource venv/bin/activate\npython -m pip install -r dev_requirements.txt\n```\n\nYou may also raise a `PR` to get merged into existing project.\n\nHappy Warming.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsatyamsoni2211%2Flambdawarmerpy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsatyamsoni2211%2Flambdawarmerpy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsatyamsoni2211%2Flambdawarmerpy/lists"}