{"id":51129950,"url":"https://github.com/osisdie/dotnet-aws-lambda-keep-awake","last_synced_at":"2026-06-25T11:01:32.080Z","repository":{"id":38060132,"uuid":"202999795","full_name":"osisdie/dotnet-aws-lambda-keep-awake","owner":"osisdie","description":"Keep your AWS Lambda functions warm with 4 creative self-awakening strategies (S3/SQS/CPU/MEM). No more cold starts! .NET 10 + ASP.NET Core + SAM","archived":false,"fork":false,"pushed_at":"2026-03-23T22:20:19.000Z","size":51,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-24T21:13:15.892Z","etag":null,"topics":["aspnetcore","aws-lambda","cold-start","dotnet","keep-alive","keep-warm","lambda-warmup","serverless"],"latest_commit_sha":null,"homepage":"","language":"C#","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/osisdie.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-08-18T12:23:31.000Z","updated_at":"2026-03-23T22:20:53.000Z","dependencies_parsed_at":"2025-01-16T02:14:28.294Z","dependency_job_id":"226a8af9-10cc-4871-86b5-439a102889c9","html_url":"https://github.com/osisdie/dotnet-aws-lambda-keep-awake","commit_stats":null,"previous_names":["osisdie/dotnet-aws-lambda-keep-awake"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/osisdie/dotnet-aws-lambda-keep-awake","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osisdie%2Fdotnet-aws-lambda-keep-awake","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osisdie%2Fdotnet-aws-lambda-keep-awake/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osisdie%2Fdotnet-aws-lambda-keep-awake/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osisdie%2Fdotnet-aws-lambda-keep-awake/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/osisdie","download_url":"https://codeload.github.com/osisdie/dotnet-aws-lambda-keep-awake/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osisdie%2Fdotnet-aws-lambda-keep-awake/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34771664,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-25T02:00:05.521Z","response_time":101,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["aspnetcore","aws-lambda","cold-start","dotnet","keep-alive","keep-warm","lambda-warmup","serverless"],"created_at":"2026-06-25T11:01:30.162Z","updated_at":"2026-06-25T11:01:32.067Z","avatar_url":"https://github.com/osisdie.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dotnet-aws-lambda-keep-awake\n\n[![.NET](https://img.shields.io/badge/.NET-10.0-512BD4)](https://dotnet.microsoft.com)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n[![GitHub Actions](https://github.com/osisdie/dotnet-aws-lambda-keep-awake/actions/workflows/dotnet.yml/badge.svg)](https://github.com/osisdie/dotnet-aws-lambda-keep-awake/actions)\n[![GitHub last commit](https://img.shields.io/github/last-commit/osisdie/dotnet-aws-lambda-keep-awake)](https://github.com/osisdie/dotnet-aws-lambda-keep-awake/commits/main)\n[![AWS Lambda](https://img.shields.io/badge/AWS-Lambda-orange)](https://aws.amazon.com/lambda/)\n[![Awakers](https://img.shields.io/badge/Awakers-4-green)](#built-in-awaker-plugins)\n\n\u003e Keep your AWS Lambda functions warm with creative self-awakening strategies. No more cold starts!\n\nA .NET 10 AWS Lambda Serverless WebAPI template with **4 built-in Awaker plugins** that periodically exercise your Lambda function to prevent cold start delays. Easily extensible with custom awakers.\n\n*Part of the **code_for_fun** series*\n\n---\n\n## Architecture\n\n```\n                    +-----------------------+\n                    |   API Gateway         |\n                    |   /{proxy+}           |\n                    +-----------+-----------+\n                                |\n                    +-----------v-----------+\n                    |   Lambda Function     |\n                    |   (ASP.NET Core 10)   |\n                    +-----------+-----------+\n                                |\n                    +-----------v-----------+\n                    |   SelfAwakeService    |\n                    |   (Timer-based)       |\n                    +---+---+---+---+-------+\n                        |   |   |   |\n              +---------+   |   |   +---------+\n              |             |   |             |\n        +-----v----+  +----v---v-+  +--------v---+\n        | S3 Awaker|  |SQS Awaker|  | CPU Awaker |\n        +----------+  +----------+  +------------+\n                                    | MEM Awaker |\n                                    +------------+\n```\n\nThe `SelfAwakeService` runs a background timer that periodically invokes all enabled Awaker plugins. Each plugin performs a lightweight operation (S3 list, SQS poll, CPU/MEM burst) to keep the Lambda container active.\n\n## Prerequisites\n\n- [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0)\n- [AWS CLI v2](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)\n- [AWS SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html) (for deployment)\n- An AWS account with Lambda, S3, and optionally SQS permissions\n\n## Quick Start\n\n### 1. Clone and restore\n\n```bash\ngit clone https://github.com/osisdie/dotnet-aws-lambda-keep-awake.git\ncd dotnet-aws-lambda-keep-awake\ndotnet restore\n```\n\n### 2. Run locally\n\n```bash\ncd AWSServerlessSleepless.Host\ndotnet run\n# Listening on http://localhost:5001\n```\n\n### 3. Test the endpoint\n\n```bash\ncurl http://localhost:5001/\n# Returns JSON status with echo count, generated ID, and awaker stats\n```\n\n## Configuration\n\nAll awaker settings live in `appsettings.json`:\n\n### Main Service (Orchestrator)\n\n| Key | Type | Default | Description |\n|-----|------|---------|-------------|\n| `Enabled` | bool | `true` | Enable/disable the self-awake service |\n| `DelayStartInSecs` | int | `1` | Seconds to wait before first awake cycle |\n| `PeriodInSecs` | int | `60` | Interval between awake cycles |\n\n```json\n\"ServerlessSleepless.Host.Services.SelfAwakeService\": {\n    \"Enabled\": true,\n    \"DelayStartInSecs\": 1,\n    \"PeriodInSecs\": 60\n}\n```\n\n## Built-in Awaker Plugins\n\n| # | Plugin | Strategy | Config Keys |\n|---|--------|----------|-------------|\n| 1 | **AccessS3** | Lists S3 bucket objects | `BucketName` |\n| 2 | **SQSLoop** | Consumes \u0026 publishes SQS messages | `QueueUrl`, `Region`, `MaxNumberOfMessages` |\n| 3 | **BurstCPU** | Shuffles large arrays to spike CPU | `MaxProcessCount` (default: 1,000,000) |\n| 4 | **BurstMEM** | Allocates memory blocks | `MinMemSizeMB`, `MaxMemSizeMB` |\n\n### Plugin Configuration Examples\n\n```json\n\"ServerlessSleepless.Awaker.AccessS3.SelfAwakeService\": {\n    \"Enabled\": true,\n    \"BucketName\": \"your-bucket-name\"\n},\n\"ServerlessSleepless.Awaker.SQSLoop.SelfAwakeService\": {\n    \"Enabled\": false,\n    \"PublishMessageOnStartup\": true,\n    \"MaxNumberOfMessages\": 10,\n    \"Region\": \"us-west-2\",\n    \"ServiceUrl\": \"http://sqs.us-west-2.amazonaws.com\",\n    \"QueueUrl\": \"https://sqs.us-west-2.amazonaws.com/ACCOUNT_ID/queue-name\",\n    \"DelayStartInSecs\": 1,\n    \"PeriodInSecs\": 60\n},\n\"ServerlessSleepless.Awaker.BurstCPU.SelfAwakeService\": {\n    \"Enabled\": true,\n    \"MaxProcessCount\": 1000000\n},\n\"ServerlessSleepless.Awaker.BurstMEM.SelfAwakeService\": {\n    \"Enabled\": true,\n    \"MinMemSizeMB\": 128,\n    \"MaxMemSizeMB\": 512\n}\n```\n\n## Create Your Own Awaker\n\nYou can easily create a custom awaker plugin:\n\n1. **Create a new class library** targeting `net8.0;net10.0`\n2. **Inherit from** `SelfAwakerServiceBase` and implement two abstract methods:\n   - `InitializeIfEnabled()` — setup logic when the plugin is enabled\n   - `TryAwake()` — the actual keep-warm operation\n3. **Add configuration** in `appsettings.json` with the `Enabled` key to toggle it on/off\n4. **Register the assembly** in `Startup.cs`:\n\n```csharp\nservices.AddSingleton\u003cISelfAwakeService\u003e(new SelfAwakeService(Configuration,\n    typeof(Awaker.AccessS3.SelfAwakeService).Assembly,\n    typeof(Awaker.SQSLoop.SelfAwakeService).Assembly,\n    typeof(Awaker.BurstCPU.SelfAwakeService).Assembly,\n    typeof(Awaker.BurstMEM.SelfAwakeService).Assembly,\n    typeof(YourCustom.SelfAwakeService).Assembly  // Add your assembly here\n));\n```\n\n## Deploy to AWS\n\n### Using AWS SAM CLI\n\n```bash\ncd AWSServerlessSleepless.Host\n\n# Build the Lambda package\nsam build\n\n# Deploy (guided mode for first-time setup)\nsam deploy --guided\n```\n\n### Using AWS Lambda Tools\n\n```bash\ncd AWSServerlessSleepless.Host\n\n# Install the Lambda tools\ndotnet tool install -g Amazon.Lambda.Tools\n\n# Deploy the serverless application\ndotnet lambda deploy-serverless\n```\n\n### CloudFormation Template\n\nThe included `serverless.template` configures:\n- **Runtime**: `provided.al2023` (self-contained .NET 10)\n- **Memory**: 512 MB\n- **Timeout**: 30 seconds\n- **API Gateway**: Proxy integration for all routes\n- **S3 Bucket**: Optional auto-creation via parameters\n\n### EventBridge Keep-Warm Rule (Recommended)\n\nFor maximum effectiveness, add a CloudWatch EventBridge rule to invoke your Lambda every 5 minutes:\n\n```bash\naws events put-rule \\\n    --name \"keep-lambda-warm\" \\\n    --schedule-expression \"rate(5 minutes)\"\n\naws lambda add-permission \\\n    --function-name YOUR_FUNCTION_NAME \\\n    --statement-id keep-warm-event \\\n    --action lambda:InvokeFunction \\\n    --principal events.amazonaws.com\n\naws events put-targets \\\n    --rule \"keep-lambda-warm\" \\\n    --targets \"Id=1,Arn=YOUR_FUNCTION_ARN\"\n```\n\n## Project Structure\n\n```\nServerlessSleepless.sln\n├── AWSServerlessSleepless.Host/          # Lambda WebAPI host (net10.0)\n│   ├── Controllers/                       # API endpoints\n│   ├── Services/                          # SelfAwakeService orchestrator\n│   ├── serverless.template                # SAM/CloudFormation template\n│   └── appsettings.json                   # All awaker configurations\n├── ServerlessSleepless.Awaker.Abstraction/  # Interfaces (IPleaseAwakeMyselfService)\n├── ServerlessSleepless.Awaker.Common/       # Base class (SelfAwakerServiceBase)\n├── ServerlessSleepless.Awaker.AccessS3/     # S3 awaker plugin\n├── ServerlessSleepless.Awaker.SQSLoop/      # SQS awaker plugin\n├── ServerlessSleepless.Awaker.BurstCPU/     # CPU burst awaker plugin\n├── ServerlessSleepless.Awaker.BurstMEM/     # Memory burst awaker plugin\n└── ServerlessSleepless.Logging/             # Log4net + CloudWatch integration\n```\n\n## Contributing\n\nContributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.\n\nIdeas for new awakers:\n- **DynamoDB Awaker** — Read/write to a DynamoDB table\n- **HTTP Awaker** — Ping an external health endpoint\n- **CloudWatch Awaker** — Publish a custom metric\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fosisdie%2Fdotnet-aws-lambda-keep-awake","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fosisdie%2Fdotnet-aws-lambda-keep-awake","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fosisdie%2Fdotnet-aws-lambda-keep-awake/lists"}