getting all flavors is too inefficient

Bug #1206762 reported by ruandongdong
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Invalid
Medium
tcs_openstack_group

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
Revision history for this message
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
Revision history for this message
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)

Revision history for this message
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.

Revision history for this message
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)
description: updated
description: updated
Revision history for this message
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/flavors.py
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,
                                         flavor["flavorid"],
                                         self._collection_name),
            },
        }
   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.

Revision history for this message
Joe Gordon (jogo) wrote :

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

Revision history for this message
wangpan (hzwangpan) wrote :
David Ripton (dripton)
Changed in nova:
importance: Undecided → Medium
status: New → In Progress
assignee: nobody → Aditi Raveesh (aditirav)
Revision history for this message
ruandongdong (hzrandd) wrote :

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

Matt Riedemann (mriedem)
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)
Revision history for this message
Dmitry Guryanov (dguryanov) wrote :

Hello!

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
1012

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.

Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote :

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

thanks,
dims

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

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.