0

My framework uses Python API for GCE to create instances on the fly as needed. All the instances are based on single machine image. There is a limit on the rate of the instance-creation operation. However, I noticed that sometimes GCE allows the creation of several instances in a row without much delay. Hence, I do not want to fix the delay between instance creations in my code.

For now, I use exponentially increasing delays between attempts at instance creation. Although I could not find anything related in the documentation, I decided to try asking: is there a way to use the API to find out directly when the next instance creation will be allowed?

AlwaysLearning
  • 7,257
  • 4
  • 33
  • 68

1 Answers1

1

It would be helpful if your question included a minimal repro of your code, it's scope (what rate of instance creation are you attempting?) and details of the error that you're receiving.

Although not surprising (!), I was unaware that there is a rate limit on instance creation (instances.insert).

The Compute Engine API rate limits does not appear (!?) to include instances.insert.

If you're hitting a rate limit you can:

  1. Use Cloud Monitoring (libraries) to monitor API usage. For a non-programmatic (!) check, API dashboard is easier.
  2. It's good practice to include a feedback mechanism in your code. For example, if you encounter service-side errors (5XX), you should backoff retries.
  3. You can request more Compute Engine quota using Cloud console.

It's possible that you're encountering service capacity limits (I've seen these recently in us-east1). There is insufficient capacity to fulfill your requests in the region|zone. In this case, the only alternative is to look in other regions|zones for capacity.

DazWilkin
  • 32,823
  • 5
  • 47
  • 88
  • It is certainly a rate limit, as my code always succeeds in creating another instance after waiting for a few minutes. I am working on a framework for scientific experimentation, so it's for other people's use. Hence, asking for more quota is not a suitable solution. – AlwaysLearning Jun 20 '22 at 20:33