Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

ASG MaxSize is 4, but the app cannot run on more than one instance

Open
#409 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
Half a day
Newbie friendliness
25/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
aws, node.js, typescript
Domain
cloud, devops

Research direction

The mismatch is in the autoscaling configuration (aws:autoscaling:asg MaxSize, set alongside the CPU trigger from #376) and in the app's per-process state in EnvironmentService, which holds arenas in a Map. Check the ladder loop started from index.ts when LADDER_ENABLED=true. Done means MaxSize is set to 1 with the rationale recorded, but the longer-term architecture work is out of scope for a first contribution.

Written by the indexing model from the issue text.

Description

priority: high tech-debt

Noticed on 2026-10-10 during the RDS memory investigation.

The setup contradicts itself

aws:autoscaling:asg → MaxSize: 4, with the scale-up trigger at CPUUtilization > 75% sustained 10 minutes (aws:autoscaling:trigger, set by #376).

But the app is not horizontally scalable:

  • Arena state is per-process and in memory. EnvironmentService holds a Map<arenaId, Environment> in the Node process. A second instance cannot see the first's arenas, so a request routed there finds a different world.
  • SSE connections are pinned. An established /arena/events or /arena/logs stream stays on the instance that accepted it and cannot be relieved by adding more.
  • The ladder loop runs on every instance. index.ts starts it whenever LADDER_ENABLED=true, so N instances means N independent matchmakers writing ratings to the same app rows — concurrent, unsynchronised Elo updates.

A scale-out therefore does not add capacity; it forks the live state and multiplies the background load on the shared database.

How close it is

Measured over 24 h on 2026-10-10: CPU averaged 38–42% with 5-minute maxima of 64–66%, against a 75% trigger. That is one busy afternoon away.

#406's saturation cap should drop steady-state CPU to the ~20% ladder-idle baseline, which makes a breach much less likely — but it does not make a breach safe, and the ceiling is still 4.

Suggested fix

Short term: set MaxSize: 1. The trigger can stay; there is simply nowhere to scale to. This is the honest configuration for the current architecture and removes the failure mode outright.

Longer term, if scaling out is ever wanted, it needs at least:

  • a single-leader election (or a dedicated worker) for the ladder loop, so only one instance matchmakes
  • shared or sticky arena ownership, so an arena lives in one known place
  • the simulation state moved out of process, or arenas sharded by instance with routing

That is a real project, not a config change — hence the short-term fix.

Related

  • #376 replaced the (wrong) NetworkOut trigger with CPU, which fixed spurious scale-outs but left the ceiling at 4.
  • #143 (de-duplicate the simulation math) and #144 (multi-arena tooling) are adjacent but do not address this.
Dominant language
TypeScript
Stars
0
Forks
0
Avg merge
8m
Merged PRs (30d)
8

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from LeeAdcock/robocodeJs.com

All issues in LeeAdcock/robocodeJs.com

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.