> For the complete documentation index, see [llms.txt](https://docs.cortexlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cortexlabs.com/0.32/clusters/instances/multi.md).

# Multi-instance

Cortex can be configured to provision different instance types to improve workload performance and reduce cloud infrastructure spend.

## Best practices

**Node groups with lower indices have higher priority.**

1. Small instance node groups should be listed before large instance node groups.
2. CPU node groups should be listed before GPU/Inferentia node groups.
3. Spot node groups should always be listed before on-demand node groups.

## Examples

### CPU spot, CPU on-demand, and GPU on-demand

```yaml
# cluster.yaml

node_groups:
  - name: cpu-spot
    instance_type: m5.large
    spot: true
  - name: cpu-on-demand
    instance_type: m5.large
  - name: gpu-on-demand
    instance_type: g4dn.xlarge
```

### CPU on-demand, GPU on-demand, and Inferentia on-demand

```yaml
# cluster.yaml

node_groups:
  - name: cpu-on-demand
    instance_type: m5.large
  - name: gpu-on-demand
    instance_type: g4dn.xlarge
  - name: inferentia-on-demand
    instance_type: inf.xlarge
```

### 3 CPU spot and 1 CPU on-demand

```yaml
# cluster.yaml

node_groups:
  - name: cpu-1
    instance_type: t3.medium
    spot: true
  - name: cpu-2
    instance_type: m5.2xlarge
    spot: true
  - name: cpu-3
    instance_type: m5.8xlarge
    spot: true
  - name: cpu-4
    instance_type: m5.24xlarge
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.cortexlabs.com/0.32/clusters/instances/multi.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
