Everyone

Capacity Tracking & Auto-Assign

How Commerce tracks available server capacity and automatically assigns new orders to the server with the most free slots.

Last updated 1776211200

Overview

Commerce tracks how many hosting accounts each server holds and uses this to route new orders. The goal: spread accounts across servers evenly and prevent over-provisioning beyond a server's configured limit.

How Capacity Is Calculated

Free Slots = max_accounts − count(services where server_id = X AND status IN (active, suspended))
  • max_accounts — set on the server record by the admin.
  • Active + suspended services both count against capacity (suspended accounts still occupy resources on the panel).
  • Terminated services are excluded from the count.

Commerce calculates this from its own database records — it does not query the Panel API for real-time account counts.

Viewing Capacity

Go to Admin → Infrastructure → Servers. The table shows:

Column Description
Name Server label
Group Assigned server group
Module Provisioning module type
Accounts Current active + suspended service count
Max Configured max_accounts
Free Free slots remaining
Status Online / Offline (based on last test)

Auto-Assign on Order

When a new hosting order is paid, Commerce:

  1. Looks up the product's server group.
  2. Calls ServerGroup::bestServer() — returns the server with the most free slots.
  3. Sets services.server_id to that server.
  4. Dispatches CreateHostingAccountJob targeting that server.

If multiple servers have equal free slots, the first one returned by the query is selected (by ID ascending).

What Happens When All Servers Are Full

If every server in the group has free slots = 0:

  • The order is created but the service stays in pending status.
  • An admin notification is sent: "Provisioning held — no available server capacity."
  • No job is dispatched until a slot becomes available.

Resolution options:

  1. Increase max_accounts on an existing server (edit the server record).
  2. Add a new server to the group.
  3. Manually assign the service to a specific server from Admin → Services → [service] → edit.

Keeping Capacity Accurate

Because Commerce tracks its own records rather than querying the panel, you may need to manually re-sync in certain situations:

Situation Action
Accounts migrated away from a server outside Commerce Terminate the relevant service records in Commerce, or decrease max_accounts to reflect real usage.
Accounts migrated onto a server outside Commerce Increase the account count by lowering max_accounts accordingly, or create service stubs for the migrated accounts.
Accounts deleted directly on the Panel without going through Commerce Terminate the service in Commerce to free the slot.

There is no automatic sync between Panel account counts and Commerce service records. If the two diverge significantly, free slot calculations will be inaccurate.

Adjusting Max Accounts

  1. Go to Admin → Infrastructure → Servers → [server].
  2. Update the Max Accounts field.
  3. Save.

The change takes effect immediately on the next order.

Related