Work with Capacity Blocks - Amazon Elastic Compute Cloud
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Work with Capacity Blocks

To start using Capacity Blocks, you first find and purchase an available Capacity Block that matches your reservation size, duration, and timing needs. Then, when the reservation begins, you can use the Capacity Block by launching instances that target the reservation ID. Thirty minutes before the reservation expires, we begin to terminate any instances that are still running in the Capacity Block.

Capacity Blocks are delivered as targeted Capacity Reservations in a single Availability Zone. To run instances in a Capacity Block, you must specify the reservation ID when launching your instances. If you stop instances on your own and the Capacity Block expires, you can't restart them until you target another Capacity Block in the active state.

By default, Capacity Blocks deliver low-latency, high-throughput network connectivity between the instances inside the Capacity Block, so there is no need to use a cluster placement group with a Capacity Block.

Prerequisites

You must use the corresponding Amazon Web Services Region for the instance type that you want to use. For more information, see Regions.

Capacity Blocks with p5.48xlarge instances are available in following Amazon Web Services Regions.

Region name Region code

US East (Ohio)

us-west-2

US East (N. Virginia)

us-east-1

Capacity Blocks with p4d.24xlarge instances are available in following Amazon Web Services Regions.

Region name Region code

US East (Ohio)

us-west-2

US West (Oregon)

us-west-2

Note

Capacity Block sizes of 64 instances are not supported for all instance types in all Amazon Web Services Regions.

Find and purchase Capacity Blocks

To reserve a Capacity Block, you first need to find a block of time when capacity is available that matches your needs. To find a Capacity Block that is available to reserve, you specify.

  • The number of instances that you need

  • The duration of time you that you need the instances

  • The date range that you need your reservation

To search for an available Capacity Block offering, you specify a reservation duration and instance count. You must select one of the following options.

  • For reservation duration – Up to 14 days in 1-day increments

  • For instance count – 1, 2, 4, 8, 16, 32, or 64 instances

If a Capacity Block is available that matches your specifications, we return the details of a single Capacity Block offering. The offering details include the start time of the reservation, the Availability Zone for the reservation, and the price of the reservation. For more information, see Pricing.

You can purchase the Capacity Block offering you are shown, or you can modify your search criteria to see the other options that are available. There is no predefined expiration time for the offering, but offerings are only available on a first-come, first-served basis.

When you purchase a Capacity Block offering, you get an immediate response confirming that your Capacity Block was reserved. After confirmation, you will see a new Capacity Reservation in your account with a reservation type of capacity-block and a start-date set to the start time of the offering that you purchased. Your Capacity Block reservation is created with a state of payment-pending. After the upfront payment is successfully processed, the reservation state changes to scheduled. For more information, see Billing.

You can use one of the following methods to find and purchase a Capacity Block.

Console
To find and purchase a Capacity Block using the console
  1. Open the Amazon EC2 console at https://console.amazonaws.cn/ec2/.

  2. In the navigation bar at the top of the screen, select an Amazon Web Services Region. This choice is important because Capacity Block sizes of 64 instances are not supported for all instance types in all Regions.

  3. In the navigation pane, choose Capacity Reservations, Purchase Capacity Blocks.

  4. Under Capacity attributes, you can define your Capacity Block search parameters. By default, the platform is Linux. If you want to select a different operating system, use the Amazon CLI. For more information, see Supported platforms.

  5. Under Total capacity, select the number of instances you want to reserve.

  6. Under Duration, enter the number of days you need the reservation for.

  7. Under Date range to search for Capacity Blocks, enter the earliest possible start date and latest acceptable end date for your reservation.

  8. Choose Find Capacity Blocks.

  9. If a Capacity Block is available that meets your specifications, you see an offering under Recommended Capacity Blocks. If there are multiple offerings that meet your specifications, the lowest priced Capacity Block offering available is shown. To view other Capacity Block offerings, adjust your search inputs and choose Find Capacity Blocks again.

  10. When you find a Capacity Block offering that you want to purchase, choose Next.

  11. (Optional) On the Add tags page, choose Add new tag.

  12. The Review and purchase page lists the start and end date, duration, total number of instances, and price.

    Note

    Capacity Blocks can't be modified or canceled after you reserve them.

  13. In the popup window Purchase a Capacity Block, type confirm, then choose Purchase.

Amazon CLI
To find a Capacity Block using the Amazon CLI

Use the describe-capacity-block-offerings command.

The following example searches for a Capacity Block that has 16 p5.48xlarge instances with a date range starting 2023-08-14 and ending 2023-10-22 with a duration of 48 hours. The instance count must be an integer from a predefined set of options 1, 2, 4, 8,16, 32 ,64. The capacity duration must be an integer that is a multiple of 24 between 24 and 336 indicating the number of days in hours.

aws ec2 describe-capacity-block-offerings --instance-type p5.48xlarge \ --instance-count 16 --start-date-range 2023-08-14T00:00:00Z \ --end-date-range 2023-10-22-T00:00:00Z --capacity-duration 48
To purchase a Capacity Block using the Amazon CLI

Use the purchase-capacity-block command and specify the offering ID of the Capacity Block that you want to purchase and the instance platform.

aws ec2 purchase-capacity-block \ --capacity-block-offering-id cbr-0123456789abcdefg \ --instance-platform Linux/UNIX

Launch instances into Capacity Blocks

After you reserve a Capacity Block, you can view the Capacity Block reservation in your Amazon account. You can view the start-date and end-date to see when your reservation will begin and end. Before a Capacity Block reservation begins, the available capacity appears as zero. You can see how many instances will be available in your Capacity Block by the tag value for the tag key aws:ec2capacityreservation:incrementalRequestedQuantity.

When a Capacity Block reservation begins, the reservation state changes from scheduled to active. We emit an event through Amazon EventBridge to notify you that the Capacity Block is available to use. For more information, see Monitor Capacity Blocks.

To use your Capacity Block, you must specify the Capacity Block reservation ID when launching instances. Launching an instance into a Capacity Block reduces the available capacity by the number of instances launched. For example, if your purchased instance capacity is eight instances and you launch four instances, the available capacity is reduced by four.

If you terminate an instance running in the Capacity Block before the reservation ends, you can launch a new instance in its place. When you stop or terminate an instance in a Capacity Block, it takes several minutes to clean up your instance before you can launch another instance to replace it. During this time, your instance will be in a stopping or shutting-down state. After this process is complete, your instance state will change to stopped or terminated. Then, the available capacity in your Capacity Block will update to show another instance available to use.

The following steps explain how to launch instances into a Capacity Block in the active state using the Amazon Web Services Management Console or the Amazon CLI.

For information about how to set up an EKS node group to automatically use a Capacity Block when it begins, see Capacity Blocks for ML in the Amazon EKS User Guide.

For information about how to launch instances into a Capacity Block using EC2 Fleet, see Tutorial: Launch instances into Capacity Blocks.

For information about how to create a Launch Template targeting a Capacity Block, see Launch an instance from a launch template.

You can use one of the following methods to launch instances into a Capacity Block.

Console
To launch instances into a Capacity Block using the console
  1. Open the Amazon EC2 console at https://console.amazonaws.cn/ec2/.

  2. In the navigation bar at the top of the screen, select the Region for your Capacity Block reservation.

  3. From the Amazon EC2 console dashboard, choose Launch instance.

  4. (Optional) Under Name and tags, you can name your instance and tag the instance. For information about tags, see Tag your Amazon EC2 resources

  5. Under Application and OS Images, select an Amazon Machine Image (AMI).

  6. Under Instance type, select the instance type that matches your Capacity Block reservation.

  7. Under Key pair (login), choose an existing key pair or choose Create new key pair to create a new one. For more information, see Amazon EC2 key pairs and Amazon EC2 instances.

  8. Under Network settings, use the default settings, or choose Edit to configure the network settings as necessary.

    Important

    Your instance can't launch in a subnet in a different Availability Zone from the Availability Zone where your Capacity Block is located.

  9. Under Advanced details, configure the instance as follows.

    1. Under Purchasing option (market type), select Capacity Blocks.

    2. Under Capacity Reservation, select Target by ID.

    3. Select the Capacity Reservation ID of your Capacity Block reservation.

  10. On the Summary panel, for Number of instances, enter the number of instances to launch.

  11. Choose Launch instance.

Amazon CLI
To launch instances into a Capacity Block using the Amazon CLI
  • Use the run-instances command and specify a MarketType of capacity-block in the instance-market-options structure. You must also specify the capacity-reservation-specification parameter.

    The following example launches a single p5.48xlarge instance into an active Capacity Block that has matching attributes and available capacity.

    aws ec2 run-instances --image-id ami-abc12345 --count 1 \ --instance-type p5.48xlarge --key-name MyKeyPair \ --subnet-id subnet-1234567890abcdef1 \ --instance-market-options MarketType='capacity-block' --capacity-reservation-specification CapacityReservationTarget={CapacityReservationId=cr-a1234567}

View Capacity Blocks

Capacity Blocks have the following states:

  • payment-pending – The upfront payment hasn't been processed yet.

  • payment-failed—The payment couldn't be processed in the 12 hour time frame. Your Capacity Block was released.

  • scheduled – The payment was processed and the Capacity Block reservation hasn't started yet.

  • active – The reserved capacity is available for your use.

  • expired – The Capacity Block reservation expired automatically at the date and time specified in your reservation request. The reserved capacity is no longer available for your use.

You can use one of the following methods to view your Capacity Block reservation.

Console
To view Capacity Blocks using the console
  1. Open the Amazon EC2 console at https://console.amazonaws.cn/ec2/.

  2. In the navigation pane, choose Capacity Reservations.

  3. On the Capacity Reservations overview page, you see a resource table with details about all of your Capacity Reservation resources. To find your Capacity Blocks reservations, select Capacity Blocks from the dropdown list above Capacity Reservation ID. In the table, you can see information about your Capacity Blocks such as start and end dates, duration, and status.

  4. For more details about a Capacity Block, select the reservation ID for the Capacity Block that you want to view. The Capacity Reservation details page displays all the properties of the reservation and the number of instances in use and available in the Capacity Block.

    Note

    Before a Capacity Block reservation begins, the available capacity appears as zero. You can see how many instances will be available when the Capacity Block reservation starts by using the following tag value for the tag key: aws:ec2capacityreservation:incrementalRequestedQuantity.

Amazon CLI
To view Capacity Blocks using the Amazon CLI

By default, when you use the describe-capacity-reservations command both On-Demand Capacity Reservations and Capacity Block reservations are listed. To view only your Capacity Block reservations, filter using capacity-block for the capacity-reservation-type parameter.

For example, the following command describes one or more of your Capacity Block reservations in your current Amazon Web Services Region.

aws ec2 describe-capacity-reservations -reservation-type capacity-block

Example output.

{ "CapacityReservations": [ { "CapacityReservationId": "cr-12345678", "EndDateType": "limited", "ReservationType": "capacity-block" "AvailabilityZone": "eu-east-2a", "InstanceMatchCriteria": "targeted", "EphemeralStorage": false, "CreateDate": "2023-11-29T14:22:45Z", "StartDate": "2023-12-15T12:00:00Z", "EndDate": "2023-08-19T12:00:00Z", "AvailableInstanceCount": 0, "InstancePlatform": "Linux/UNIX", "TotalInstanceCount": 16, "State": "payment-pending", "Tenancy": "default", "EbsOptimized": true, "InstanceType": "p5.48xlarge" }, ...