Delay AWS API response for spot requests

0

I have a golang program, it uses ec2.Client.DescribeSpotInstanceRequests to get status of a spot request.

When a spot request is successfully created with ec2.ClientRequestSpotInstances, the request is immediately visible in aws console, but not via the API.

The delay is obvious, like 10 seconds or so.

What's going on here? Is that by design?

asked 18 days ago33 views
1 Answer
0

The behavior you're experiencing with the delay between when a Spot Instance request is visible in the AWS console versus when it's available through the API is indeed by design and is a common occurrence when working with AWS services.

When you create a Spot Instance request using RequestSpotInstances, the request is immediately recorded in AWS's systems, which is why it appears quickly in the AWS console. However, the API calls, including DescribeSpotInstanceRequests, may experience a slight delay in reflecting this information due to eventual consistency.

Eventual consistency is a model used by distributed systems like AWS to achieve high availability. It means that changes made in one part of the system may take some time to propagate to all other parts. In this case, the creation of your Spot Instance request needs time to replicate across all of AWS's data centers and become visible to API calls.

This delay, which you've observed to be around 10 seconds, is normal and expected behavior. It's not a flaw but rather a trade-off for the scalability and reliability of the AWS infrastructure.

To handle this in your Golang program, you might want to implement a polling mechanism with appropriate waits and retries when calling DescribeSpotInstanceRequests. This would allow your program to account for the propagation delay and ensure it captures the Spot Instance request information once it becomes available through the API.

Remember that Spot Instance requests can be in various states, including 'open', 'active', 'failed', 'closed', 'disabled', and 'cancelled'. The 'open' state indicates that the request is waiting to be fulfilled, which is likely what you'll see initially after creating the request.
Sources
DescribeSpotInstanceRequests - Amazon Elastic Compute Cloud
How Spot Instances work - Amazon Elastic Compute Cloud

profile picture
answered 18 days ago
  • I have a polling implemented already. But this design is stupid. I made the call via API, but the API endpoint is delayed, and the console stays up to date.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions