oiyai / docs
Services

Scale to zero, wake, and task protection

Release idle compute without mistaking a quiet task for a finished one.

Container-level scale-to-zero

Oiy implements scale-to-zero through idle sleep: an idle service releases its compute allocation, then wakes on demand. The default idle timeout is 15 minutes. Configure 1–1,440 minutes, or null to disable automatic sleep. Sleeping releases compute after the runtime confirms release; provisioned storage is retained and billed.

A request to an authenticated endpoint can wake a sleeping service. Startup can take time. The proxy waits up to 60 seconds; a service still starting returns 503 with Retry-After.

Protect a long task

A training job can be active without network traffic. Register explicit activity for its duration. The Python SDK context manager registers a task, sends periodic heartbeats, and releases it when the context exits, including after an exception.

from oiy_ai import Client

with Client().task("SERVICE_ID", name="Training"):
    train()  # Your own training function.

Install the SDK from the Python setup guide before using this example. train() is illustrative and must be supplied by your application.

Inside a managed instance

The runtime injects OIY_API_URL, OIY_ACCOUNT_ID, OIY_SERVICE_ID, and OIY_TASK_TOKEN. These scoped credentials can protect activity for that service only. They do not grant billing, service creation, or administrative access. You do not need a personal API key in a container just for task protection.

Stale activity

A missing heartbeat does not prove a task finished. Stale task leases conservatively block automatic sleep until released or until the runtime reports resource release. If a client crashes or loses connectivity, confirm the job ended before releasing its activity in the console.

HTTP response streams and WebSockets hold activity while connected. Use explicit task tracking for work that continues after a network request ends.

On this page