Search This Blog

Sunday, July 29, 2012

How to avoid Rackspace cloud API limits when creating cloud servers (cloudservers.exceptions.OverLimit)

The Rackspace Cloud API has number of limitations. One of them is how many cloud server you can create in 1 minute. The current limitations [1] looks like:

When your program [2] tries to create more than 10 cloud servers a minute you are going to run into error and start seeing this cloudservers.exceptions.OverLimit exception.

$ python -v -t 1 -s 13 -u user -k key  run | tee log.$(date +%s).txt

Traceback (most recent call last):
  File "", line 349, in module
  File "", line 346, in run
    self.test_performance(user,key, sample, cs_count, timeout)
  File "", line 298, in test_performance
    t.test_multi_cs_perf(sample, cs_count, timeout)
  File "", line 250, in test_multi_cs_perf
    cs_records=self.cs_create_all(cs_count, i+1)
  File "", line 225, in cs_create_all
    server=self.cs_create(k, sample_nr)
  File "", line 178, in cs_create
    server=sm.create(name, image, flavor)
  File "/usr/lib/pymodules/python2.7/cloudservers/", line 172, in create
    return self._create("/servers", body, "server")
  File "/usr/lib/pymodules/python2.7/cloudservers/", line 26, in _create
    resp, body =, body=body)
  File "/usr/lib/pymodules/python2.7/cloudservers/", line 69, in post
    return self._cs_request(url, 'POST', **kwargs)
  File "/usr/lib/pymodules/python2.7/cloudservers/", line 50, in _cs_request
    resp, body = self.request(self.management_url + url, method, **kwargs)
  File "/usr/lib/pymodules/python2.7/cloudservers/", line 37, in request
    raise exceptions.from_response(resp, body)
cloudservers.exceptions.OverLimit: Too many requests... (HTTP 413)

A naive code that was used in the first version of my program was simply trying to sent as many create requests as possible. This of course is not going to work if we increase servers above the allowed limit.

Code demonstration

An exaple of the naive code.

A code that is more inteligent looks like this.


No comments:

Post a Comment