> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sfcompute.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Spot deployments

> Buy interruptible compute and maintain instances up to a target

<Warning>
  This feature is in [public preview](/preview/roadmap).
</Warning>

A spot deployment is a persistent automation that combines market-based capacity purchasing with
instance management. You create it once, and it keeps trying to buy capacity for one
[instance SKU](/preview/instance-skus) at or below a maximum rate. As capacity becomes available, it
creates instances from an [instance template](/preview/instance-templates).

SFC Spot is a buying strategy, not a separate inventory class with a fixed discount. Price and
availability depend on sell orders in the SFC market. A spot deployment maintains as many
instances as the market can supply within your maximum rate, up to your target instance count.
Unlike a request that stops after launching instances once, a Spot deployment continues buying
capacity to maintain its target.

<Warning>
  Spot capacity is interruptible. If the deployment cannot continue buying capacity within your
  maximum rate, it may run fewer instances than the target or stop running instances entirely. Use
  Spot for workloads that can tolerate interruption and recover from checkpoints or durable queues.
</Warning>

## How it works

The deployment runs a continuous loop.

1. Calculates how many more instances it needs to reach the target.
2. Places orders.
3. Adds capacity from filled orders to the selected [pool](/preview/pools).
4. Creates instances from the selected template as capacity becomes available.
5. Extends capacity purchases while matching sell orders remain available within the maximum rate.
6. Stops excess instances and offers their remaining secured capacity for sale when you lower the
   target.
7. Marks affected instances as preempting and stops them if it cannot extend their capacity.

Each buy order must fill for its entire requested contract period, but the orders fill
independently. The deployment does not wait for the complete target to become available as a
group. A target of 8 instances may therefore run anywhere from 0 to 8 instances when market
liquidity is limited. The target is a ceiling, not an availability guarantee.

If no matching sell order is available within your maximum rate, the deployment remains active and
tries again. It does not guarantee a start time or a fulfillment deadline.

## Pricing

The maximum rate is the most the deployment may pay. Filled orders execute at the matched market
price, which may be lower.

Waiting does not reserve compute. An unfilled order does not purchase capacity or incur a compute
charge. When an order fills, you purchase its complete contract period and are charged for that
period, including time while the resulting instance is starting or idle.

## When a deployment is below target

Use `sf deployments get` to inspect the reconciliation status, then review the pool's order history
to see the deployment's filled and unfilled orders.

The most common reasons for running below the target are:

1. No compatible sell orders are available within the maximum rate.
2. Only some of the independently placed buy orders can fill.
3. The account has insufficient balance to place more orders.
4. Purchased capacity is available, but instances are still starting.

## Create a spot deployment

Create a [pool](/preview/pools) and instance template first, then run the create command.

```bash theme={null}
sf deployments create \
  --type spot \
  --name batch-workers \
  --pool spot-pool \
  --instance-template batch-worker \
  --instance-sku isku_4UpxzQw7A8N \
  --target-instance-count 8 \
  --max-rate 17.00
```

`--max-rate` is measured in dollars per node-hour.

<Note>
  A spot deployment manages both capacity and instances. It cannot share the same pool and instance
  SKU with another spot deployment, procurement, or standard deployment.
</Note>

## View spot deployments

Spot and standard deployments share the same commands. The `TYPE` column identifies spot
deployments.

```bash theme={null}
sf deployments list
sf deployments get batch-workers
```

The deployment details include the instance SKU, maximum rate, target instance count, and current
reconciliation status. Spot-generated orders also appear in the pool's order history.

## Update a spot deployment

Use the standard deployment update command to change its target instance count, instance template,
name, or instance name template.

```bash theme={null}
sf deployments set batch-workers --target-instance-count 16
```

Increasing the target queues additional instances and makes the deployment buy the capacity needed
to run them. Availability still depends on matching sell orders within the maximum rate.

<Warning>
  Lowering the target is an immediate scale-down, not an attrition policy. The deployment may stop
  excess instances immediately and attempts to sell their remaining secured capacity through market
  sell orders. It does not wait for those orders to fill before stopping the instances. Market sell
  orders take the highest available rate and do not use the maximum buy rate as a sell-price floor.
  A sale depends on buyer demand. Excess capacity that does not sell remains on the pool until its
  contract period ends and produces no resale proceeds.
</Warning>

Updating the instance template only affects new instances created by the deployment.

## Pause a spot deployment

Pausing stops the deployment from placing buy or sell orders and from creating new instances.
Pending instances that have not been assigned are removed. Assigned instances continue running
until their allotted capacity ends. Resuming restarts the automation toward its configured target.

## Delete a spot deployment

```bash theme={null}
sf deployments delete batch-workers
```

Deleting a spot deployment stops it from buying more capacity. Existing capacity commitments
remain on the pool until they end. Instances that are already running continue running on that
remaining capacity.

### API reference

Spot deployments use the [Deployments API](/preview/api-reference/deployments/list-deployments).
