getting all flavors is too inefficient

Bug #1206762 reported by ruandongdong on 2013-07-31
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)

Bug Description

when i get all flavors by 'nova flavor-list',it is too inefficient.
For more details:
    i create 1600 flavors to test, it will takes 78 seconds. as we all know that 1600 kinds flavors are not much at all for we create instances with them.

In fact,it is inefficient to get extra_specs for every flavor, and then add the extra_specs information to flavor. so, it will query db 1600 times. why not get them only once from db.

Tags: db Edit Tag help
Matt Riedemann (mriedem) wrote :

I'm not sure why someone would create 1600 separate flavors in production or if this is actually unreasonable performance.

tags: added: db
ruandongdong (hzrandd) wrote :

I want to offer a variety of flavor combinations to meet all customers needs,such as:
ecus=(1 2 4 6 8 12 16 24 32)
mems=(512 1024 2048 4096 6144 8192 12288 16384 24576 32768)
ephers=(0 10 20 30 40 60 80 120 160 200)
local_disk=(20 40)

wangpan (hzwangpan) wrote :

On the other hand, even it is unreasonable to create 1000+ flavors, but there really exists an inefficient db query to get all flavors and the extra_specs of them.

ruandongdong (hzrandd) wrote :

oh,sorry, 'ecus' may be 'vcpus' for you .
vcpus=(1 2 4 6 8 12 16 24 32)
mems=(512 1024 2048 4096 6144 8192 12288 16384 24576 32768)
ephers=(0 10 20 30 40 60 80 120 160 200)
local_disk=(20 40)

ruandongdong (hzrandd) on 2013-08-06
description: updated
description: updated
ruandongdong (hzrandd) wrote :

Get all flavors by the interface 'detail',it is inefficient . because it return datas have no extra_specs information ,why not get them by the interface 'show', as we all konw: In the file of nova/api/openstack/compute/views/
def show(self, request, flavor):
    flavor_dict = {
            "flavor": {
                "id": flavor["flavorid"],
                "name": flavor["name"],
                "ram": flavor["memory_mb"],
                "disk": flavor["root_gb"],
                "vcpus": flavor.get("vcpus") or "",
                "links": self._get_links(request,
   if flavor.get('extra_specs'):
        flavor_dict['flavor']['extra_specs'] = flavor['extra_specs'] # get extra_specs information and return it here.
   return flavor_dict

At the same time,should modfiy in the novaclient.

Joe Gordon (jogo) wrote :

Matt, i think this is unreasonably bad performance. Nova is supposed to scale and this sounds like it doesn't.

David Ripton (dripton) on 2013-08-16
Changed in nova:
importance: Undecided → Medium
status: New → In Progress
assignee: nobody → Aditi Raveesh (aditirav)
ruandongdong (hzrandd) wrote :

it only return extra_specs with flavor by detail or show, but it is still inefficient.

Matt Riedemann (mriedem) on 2014-06-04
Changed in nova:
status: In Progress → Triaged
importance: Medium → Undecided
assignee: Aditi Raveesh (aditirav) → nobody
importance: Undecided → Medium
Changed in nova:
assignee: nobody → tcs_openstack_group (tcs-openstack-group)
Dmitry Guryanov (dguryanov) wrote :


I've just checked, if this problem still exists. Nova returns list of 1012 flavors in ~2 sec:

[stack@kir1 devstack]$ time nova flavor-list | wc -l

real 0m2.229s
user 0m1.437s
sys 0m0.158s

Also I turned on mysql requests log and nova executes only one query to get information from the database.

I suppose we can close this bug.

Closing bug per comment in #9. Please reopen if you still see this issue.


Changed in nova:
status: Triaged → Incomplete
Sean Dague (sdague) on 2014-09-16
Changed in nova:
status: Incomplete → Invalid
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers