New Three new products: fordway trading ERP, UEPS cloud rendering and WPECS delivery and operations View products →

UE instance scheduling: how exclusive, shared, pre-warmed and VIP modes work

Engineering By SREYUN 0 views

Behind every Pixel Streaming program is a set of UE processes, each using part of a GPU's memory and serving one or a few viewers. Which instance a new viewer joins, when instances start and stop, what happens when GPUs are full or a process crashes: these are the questions instance scheduling has to answer.

Deterministic binding: the platform creates the instance ID

Earlier Pixel Streaming setups often "guessed" which UE process belonged to which instance from port numbers or process scans, which falls apart as soon as ports clash or processes restart. UEPS generates the instance ID itself and writes it into UE's launch arguments. When UE starts, it connects to the address in its arguments and is bound to exactly the right instance the moment it connects. The launch arguments the platform generates include:

-PixelStreamingURL=ws://<gateway>:88/ue/<program>/<instance ID>
-graphicsadapter=<GPU index> -ForceRes -ResX=<width> -ResY=<height>
-PixelStreamingWebRTCFps=<fps> -RenderOffScreen -Unattended
<program-specific arguments>

The agent starts the process from an argument array (no shell, so no command injection), stops the whole process tree by PID, and only runs executables inside its allowed directories.

The instance state machine

StateMeaning
startingThe start command was sent; waiting for UE to connect as /ue/<program>/<instance ID>; past the startup timeout it counts as failed
ready / busy / idleViewers are assigned by program mode: one per instance when exclusive, up to a set number when shared
failedThe process is stopped and retried on another GPU or machine, up to 3 times
stoppingStopped after being idle longer than the reclaim time while more instances than the pre-warm target are running

If UE disconnects unexpectedly, its viewers go back to the front of the queue and the platform starts a replacement right away. UE processes launched by hand or old versions that connect without an instance ID join their program as "manual instances" and are never reclaimed.

Placement: GPU memory first

When a new instance is needed, the platform picks among candidate render machines (online, enabled and allowed for the program):

  1. the GPU with the most free memory minus reserved memory, which must be at least the memory the program declares;
  2. then the fewest instances;
  3. then the lowest GPU utilization.

Once the start command is sent, that memory is reserved until the agent's next report, so several instances are not squeezed onto one card in quick succession. Machines without NVIDIA GPUs, or with special needs, can have GPUs defined manually. Agents report CPU, memory, per-GPU utilization and memory, and their process table every 5 seconds; the platform never polls and never runs guesswork commands such as netstat or taskkill.

Scaling

The platform keeps recalculating demand:

instances to start = instances needed for the queue + pre-warm target - (free ready slots + instances starting)

The result is capped by the program's maximum instances. The pre-warm target is the minimum number of instances kept running and can follow a schedule, so warm instances are waiting before office hours or an event starts. Instances with no viewers for longer than the idle reclaim time are stopped while more than the pre-warm target are running. Administrators can also drain an instance: it gets no new viewers and stops once the current ones leave.

Two modes and two extras

  • Exclusive: one viewer per instance, for experiences that need independent interaction (walkthroughs, guided demos).
  • Shared: each instance serves up to a set number of viewers, for dashboards and presentations.
  • A fresh instance for every viewer (optional in exclusive mode): a viewer's UE is closed as soon as they leave instead of being handed to the next viewer, so no scene state or sign-in carries over; pre-warmed instances that get used are replenished automatically.
  • VIP access links: VIP viewers always go ahead of regular viewers; when the program is full (maximum instances reached or no GPU available), the regular viewer who has watched longest is disconnected and their instance goes to the VIP. The displaced viewer sees a clear message (close code 4007) and can reconnect later; other VIPs are never disconnected, and each VIP displaces at most one regular viewer. VIP status comes from a link token signed by the server and cannot be forged through URL parameters.

Takeover after restarts, and zombie instances

When an agent reconnects, it sends its current process table, and the platform takes over UE processes that are still running: nothing is launched twice and no orphans are left. Conversely, if an instance the platform already stopped connects again (for example because its process was not killed in time), the platform rejects it with close code 4009 so a "zombie" UE cannot take over viewers. Agents send a heartbeat every 30 seconds and are only marked offline after two missed replies.

Test results

In the project's test environment, 7 real browsers watched at the same time: 3 viewers of an exclusive program made the platform start 3 instances plus 1 pre-warmed spare, and 4 viewers of a shared program shared a single instance; all went through the TCP relay at 23 to 30 fps with zero packet loss. After restarting the platform container, running UE processes reconnected within a second and were taken over without being relaunched.

In short

Deterministic binding ends the guessing about which process is which instance, GPU-memory-first placement prevents overcommitting cards, queueing, pre-warming and reclaim balance experience against cost, and takeover plus zombie rejection make restarts safe. See the UEPS product page for more.

Related articles