Skip to content

Conversation

@Sayan-
Copy link
Collaborator

@Sayan- Sayan- commented Sep 26, 2025

Overview

Adding the stz controller into the websocket pathway! It's likely unnecessary with the total volume of data flowing through the webrtc conn but it's ~free and guarantees the browser instance won't be standby'es while the connection is up

Integrating is just adding the following lines to the neko.yaml:

scaletozero:
  enabled: true

Testing

# from the root of this repo I ran:
> ./build base -r sayan.io/neko

# then in kernel-images I modified the associated files
> git diff Dockerfile
- FROM ghcr.io/onkernel/neko/base:3.0.6-v1.0.1 AS neko
+ FROM sayan.io/neko/base:latest AS neko

> git diff neko.yaml
+ scaletozero:
+   enabled: true

# then build + ran the container locally, showing selected output
> ./build-docker.sh && ./run-docker.sh

[neko] 12:12AM INF scale-to-zero plugin enabled module=scaletozero
[neko] 12:12AM INF plugin started module=plugins plugin=scaletozero

# then I connected & disconnected
[neko] 12:12AM INF connection started, disabling scale-to-zero (pending: 1) module=scaletozero
[neko] 12:12AM INF connection started, disabling scale-to-zero (pending: 0) module=scaletozero

# then I re-connected + `supervisorctl stop neko`'ed
[neko] 12:24AM INF connection started, disabling scale-to-zero (pending: 1) module=scaletozero
[neko] 12:24AM INF shutdown started, re-enabling scale-to-zero (pending: 1) module=scaletozero

TL;DR

This PR introduces a scaletozero plugin to reduce resource consumption by scaling services down when not in use. It also upgrades the server's Go version to 1.25.

Why we made these changes

To reduce operational costs and resource footprint by automatically scaling services to zero when there are no active user sessions. The Go version was upgraded to stay current with language improvements and security updates.

What changed?

  • Added scaletozero Plugin:

    • Introduced a new plugin that hooks into the session lifecycle to manage scaling.
    • Scaling is disabled when a user connects and re-enabled upon disconnection or shutdown.
    • Added a scaletozero.enabled configuration flag in neko.yaml.
    • Registered the plugin in the main plugin manager.
  • Build & Dependencies:

    • Upgraded the Go version from 1.24 to 1.25 in server/Dockerfile and server/Dockerfile.bookworm.
    • Updated go.mod and go.sum to reflect the new Go version and dependency changes.

Validation

The following manual tests were performed:

  1. Built the neko base image with the changes.
  2. Modified neko.yaml to enable the plugin:
    scaletozero:
      enabled: true
  3. Built and ran the container locally. Verified the plugin was enabled from the logs:
    [neko] 12:12AM INF scale-to-zero plugin enabled module=scaletozero
    [neko] 12:12AM INF plugin started module=plugins plugin=scaletozero
    
  4. Connected and disconnected a client, verifying that scaling was disabled and re-enabled correctly via logs.
  5. Connected a client and stopped the neko service, verifying that scaling was re-enabled on shutdown.

Description generated by Mesa. Update settings

@Sayan- Sayan- mentioned this pull request Sep 26, 2025
2 tasks
@Sayan- Sayan- force-pushed the sayan/kernel-372-simplify-api-proxy-chain branch from 7be3e08 to 2406a44 Compare September 26, 2025 22:32
@Sayan- Sayan- changed the base branch from master to sync/upstream-20250926 September 26, 2025 22:32
Copy link

@mesa-dot-dev mesa-dot-dev bot left a comment

Choose a reason for hiding this comment

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

Performed full review of 826e0c9...7be3e08

Analysis

  1. Session Tracking Logic Flaw: The controller is disabled on every connection but only enabled on disconnection, creating an imbalance that could leave the system in an incorrect state when handling multiple simultaneous connections.

  2. Race Condition Vulnerability: The pending session counter can become negative due to race conditions between connection/disconnection events, especially with pre-existing sessions. The mutex doesn't solve the fundamental counting logic issue.

  3. Missing Error Handling: Calls to controller.Disable() and controller.Enable() lack error handling, potentially causing silent failures and inconsistent system states.

  4. External Dependency Risk: Heavy reliance on an external scaling library without adequate error handling or behavior validation.

Tip

⚡ Quick Actions

This review was generated by Mesa.

Actions:

Slash Commands:

  • /review - Request a full code review
  • /review latest - Review only changes since the last review
  • /describe - Generate PR description. This will update the PR body or issue comment depending on your configuration
  • /help - Get help with Mesa commands and configuration options

5 files reviewed | 0 comments | Review on Mesa | Edit Reviewer Settings

@Sayan- Sayan- changed the title [wip] scale to zero plugin Adfd scale to zero plugin Sep 27, 2025
@Sayan- Sayan- changed the title Adfd scale to zero plugin Add scale to zero plugin Sep 27, 2025
@Sayan- Sayan- requested a review from rgarcia September 27, 2025 00:27
@Sayan- Sayan- changed the base branch from sync/upstream-20250926 to master September 29, 2025 22:33
@Sayan- Sayan- merged commit 4de1444 into master Sep 29, 2025
@Sayan- Sayan- mentioned this pull request Sep 30, 2025
2 tasks
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.

3 participants