Skip to content

feat: lazy multi-instance scaling and expose instance ID - #6

Open
harshbhx wants to merge 3 commits into
masterfrom
main
Open

feat: lazy multi-instance scaling and expose instance ID#6
harshbhx wants to merge 3 commits into
masterfrom
main

Conversation

@harshbhx

Copy link
Copy Markdown
Member

No description provided.

Copilot AI lite review requested due to automatic review settings August 13, 2026 18:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds multi-instance request distribution for the Cloudflare Worker (lazy container scaling) and exposes the handling container’s instance identifier via the API health endpoints to support load testing/diagnostics.

Changes:

  • Update the Cloudflare Worker to route requests across multiple container instances using getRandom(..., INSTANCE_COUNT).
  • Change the Worker cron trigger behavior from container pre-warming to a lightweight heartbeat log.
  • Add instanceId to /health and /api/health responses using CLOUDFLARE_DURABLE_OBJECT_ID (fallback: "local").

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/DualMind.API/Controllers/HealthController.cs Adds instanceId to health responses for identifying the serving container instance.
cf-worker/src/index.js Switches to randomized multi-instance routing and adjusts cron behavior to a heartbeat.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cf-worker/src/index.js Outdated
Comment on lines +87 to +88
async fetch(request, env, ctx) {
const container = getContainer(env.DUALMIND_CONTAINER, "default");
const container = getRandom(env.DUALMIND_CONTAINER, INSTANCE_COUNT);
Comment thread cf-worker/src/index.js
Comment on lines 4 to 7
* This Worker orchestrates the DualMind ASP.NET Core container:
* - Routes all HTTP requests to the container
* - Keeps the container warm via cron trigger (every 5 min)
* - Routes all HTTP requests across multiple container instances (getRandom)
* - Keeps ALL instances warm via cron trigger (every 5 min)
* - Auto-sets Telegram webhook URL on deploy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants