# Instance families and custom shapes

Pick a machine by its shape, general purpose, compute or memory, shared or dedicated, in steps from 1 to 64 vCPU, or make a custom shape on our own hosts.

An instance's shape is its vCPU and its memory. Shapes come in **families**, each with a fixed
ratio of memory to vCPU, and every family comes in the same **steps**:

| Family          | Memory per vCPU | Steps (vCPU)            | Names                                       | Disk                    |
| --------------- | --------------- | ----------------------- | ------------------------------------------- | ----------------------- |
| General purpose | 4 GiB           | 1, 2, 4, 8, 16, 32, 64  | `general-8` (8 vCPU, 32 GiB)                | 20 GB per vCPU, ≥ 40 GB |
| Compute         | 2 GiB           | 1, 2, 4, 8, 16, 32, 64  | `compute-8` (8 vCPU, 16 GiB)                | 20 GB per vCPU, ≥ 40 GB |
| Memory          | 8 GiB           | 2, 4, 8, 16, 32, 64     | `memory-8` (8 vCPU, 64 GiB)                 | 40 GB per vCPU          |
| Dedicated …     | as the family   | the family's even steps | `dedicated-general-8`, `dedicated-memory-4` | as the family           |
| Custom          | 1 to 8 GiB      | any count from 1 to 64  | `custom-6x24` (6 vCPU, 24 GiB)              | 20 GB per vCPU, ≥ 40 GB |

The name says the shape: `<family>-<vCPU>`, with `dedicated-` in front for cores reserved for you.
A shared vCPU shares its core with other customers (four vCPU per host thread); a dedicated one does
not, and comes in even counts so that two customers never share the two threads of one core. Memory
is never shared. More disk than the shape's is a [volume](create-and-attach-a-volume.md).

`dcloud ec2 instance-shapes list` (`GET /ec2/api/instance-shapes`) lists every family and step for
your organization, with its price, where it runs and whether it can be launched now. In the
console, the **Instance type** field of the launch form and of a new database lists them grouped by
family, each with its price.

## Where a shape runs

Where your organization's machines run decides what a shape is:

- **On our own hosts**, every family and step exists exactly, and a custom shape too. A shape is
  priced from two rates, the same for every family: a price per vCPU (shared or dedicated) and a
  price per GiB of memory, billed per started hour. The list says when no host has room for a shape
  right now (`available: false`, with the reason); no machine has more vCPU than the host it runs
  on has threads.
- **On rented capacity**, a shape runs as the smallest type there that has at least its vCPU and
  memory, and you pay that type's price. The list and the launch form say what it runs as:
  `general-2` (2 vCPU, 8 GiB) runs as `performance-4` (4 vCPU, 8 GiB), the same machine as
  `compute-4`. A shared shape never runs as a dedicated type. Shapes no rented type fits, such as
  `memory-8` and up or `general-16` and up, are listed as made on our own hosts only, and a launch
  of one is refused with that reason.

## Custom shapes

On our own hosts, pick any vCPU count from 1 to 64 and whole GiB of memory from 1 to 8 GiB per
vCPU: `custom-6x24` is 6 vCPU and 24 GiB, `dedicated-custom-6x24` the same with dedicated cores. In
the console, open **Custom shape…** under the **Instance type** field. A custom shape that is
exactly a family's step takes that step's name (`custom-8x32` launches as `general-8`).

```bash
dcloud ec2 instances run --region-id de1 --server-type custom-6x24 \
  --image-id 114690387 --name worker-01
```

Outside the band the launch is refused with `400` and the range that fits, for example "Memory must
be 1 to 8 GiB per vCPU: 64 vCPU takes 64 to 512 GiB". On rented capacity a custom shape is refused
with the nearest family step there: "custom-6x12 is a custom shape, made on our own hosts only. The
nearest class here is compute-8 (8 vCPU · 16 GiB)."

## Changing shape

On rented capacity a resize takes any shape name (`--server-type general-4`) and moves the
instance to the type that shape runs as, in one operation: the machine shuts down, gets the new
vCPU and memory, and starts again, so expect an interruption of about a minute; the disk stays as it
is. See [Resize an instance](resize-an-instance.md). On our own hosts a resize is not offered yet:
launch a new instance of the shape you want.

## Names from before

Every name that worked before still does: the rented types (`performance-2`, `dedicated-8`,
`standard-4`, `arm-2`), the size classes (`s-2`, `d-8`) and the provider's own type names.
`dedicated-8` is the same machine as `dedicated-general-8`. On our own hosts, an instance launched
before the families reads by its shape: a 2 vCPU / 4 GiB machine is `compute-2`, a 2 vCPU / 2 GiB
one `custom-2x2`.

## Related

- [Instance types, images and zones](instance-types-and-zones.md)
- [Size classes and their floor](size-classes.md)
- [Instances on your own hosts](own-hosts.md)
- `ec2.instance-shapes.list` · `dcloud ec2 instance-shapes list`
