Comment 2 for bug 1715570

Revision history for this message
Bhagyashri Shewale (bhagyashri-shewale) wrote :

Hi all,

To fix this issues they are three solutions which are mentioned below:

Solution 1:

Check the instance is booted from volume or not by calling the dp api and if it's booted from volume then set the flavor.root_gb as 0.

Drawback:

This causes the perfomance issue while getting usages.

Checked the time required to get 1000 instance usages using simple tenant usage api on solution 1 and on current master but seems that it's taking double time to get usages on Solution 1.

You can see the time difference below:

Time taken to take instance usage on master:

1. $ time nova usage --tenant b844ea0d94cb41d289f70e02bf555d15

+---------+--------------+-----------+---------------+
| Servers | RAM MB-Hours | CPU Hours | Disk GB-Hours |
+---------+--------------+-----------+---------------+
| 1000 | 662.61 | 1.29 | 1.29 |
+---------+--------------+-----------+---------------+

real 0m3.325s
user 0m1.660s
sys 0m0.128s

2. $ time nova usage --tenant b844ea0d94cb41d289f70e02bf555d15

+---------+--------------+-----------+---------------+
| Servers | RAM MB-Hours | CPU Hours | Disk GB-Hours |
+---------+--------------+-----------+---------------+
| 1000 | 662.61 | 1.29 | 1.29 |
+---------+--------------+-----------+---------------+

real 0m3.298s
user 0m1.676s
sys 0m0.120s

3. $ time nova usage --tenant b844ea0d94cb41d289f70e02bf555d15

+---------+--------------+-----------+---------------+
| Servers | RAM MB-Hours | CPU Hours | Disk GB-Hours |
+---------+--------------+-----------+---------------+
| 1000 | 662.61 | 1.29 | 1.29 |
+---------+--------------+-----------+---------------+

real 0m3.372s
user 0m1.672s
sys 0m0.108s

Average time: 3 sec

Time taken to take instances usage on Solution 1:

1. $ time nova usage --tenant b844ea0d94cb41d289f70e02bf555d15

+---------+--------------+-----------+---------------+
| Servers | RAM MB-Hours | CPU Hours | Disk GB-Hours |
+---------+--------------+-----------+---------------+
| 1000 | 662.61 | 1.29 | 0.00 |
+---------+--------------+-----------+---------------+
real 0m7.762s
user 0m1.680s
sys 0m0.128s

2. $ time nova usage --tenant b844ea0d94cb41d289f70e02bf555d15

+---------+--------------+-----------+---------------+
| Servers | RAM MB-Hours | CPU Hours | Disk GB-Hours |
+---------+--------------+-----------+---------------+
| 1000 | 662.61 | 1.29 | 0.00 |
+---------+--------------+-----------+---------------+

real 0m6.922s
user 0m1.644s
sys 0m0.160s

3. $ time nova usage --tenant b844ea0d94cb41d289f70e02bf555d15

+---------+--------------+-----------+---------------+
| Servers | RAM MB-Hours | CPU Hours | Disk GB-Hours |
+---------+--------------+-----------+---------------+
| 1000 | 662.61 | 1.29 | 0.00 |
+---------+--------------+-----------+---------------+

real 0m6.839s
user 0m1.672s
sys 0m0.092s

Average time: 7 sec

Solution 2:

Tried to get the usages information from the placement api: There are two placement api we can get the usages info which are mentioned below:

1. get allocations for instance using the placement api GET /allocations/{instance_uuid}
2. get total usages for specific tenant/project_id using GET /usages?project_id=

Drawback:

Once the instance get deleted the allocations records from placement db get deleted, so usages will be shown as 0 because of this user will not get deleted instance usages So it’s not possible to use placement api's to fix this issue.

So from above two solutions drawback I have thought about solution 3which is mentioned below:

Solution 3:

Checked if instance.image_ref then consider info[disk_gb] as(instance.flavor.root_gb + instance.flavor.ephemeral_gb) aelse consider 0 that means if instance is booted from image then local_gb will be taken as instance.flavor.root_gb else take it as 0.

This solution is not causing any perfomance issue.

Time taken on current master:

$ time nova usage --tenant afe3257305514254a4ae6c451bb23804

+---------+--------------+-----------+---------------+
| Servers | RAM MB-Hours | CPU Hours | Disk GB-Hours |
+---------+--------------+-----------+---------------+
| 1000 | 632.89 | 1.24 | 1.24 |
+---------+--------------+-----------+---------------+

real 0m3.937s
user 0m1.732s
sys 0m0.096s

$ time nova usage --tenant afe3257305514254a4ae6c451bb23804

+---------+--------------+-----------+---------------+
| Servers | RAM MB-Hours | CPU Hours | Disk GB-Hours |
+---------+--------------+-----------+---------------+
| 1000 | 632.89 | 1.24 | 1.24 |
+---------+--------------+-----------+---------------+

real 0m3.369s
user 0m1.660s
sys 0m0.112s

$ time nova usage --tenant afe3257305514254a4ae6c451bb23804

+---------+--------------+-----------+---------------+
| Servers | RAM MB-Hours | CPU Hours | Disk GB-Hours |
+---------+--------------+-----------+---------------+
| 1000 | 632.89 | 1.24 | 1.24 |
+---------+--------------+-----------+---------------+

real 0m3.272s
user 0m1.668s
sys 0m0.136s

Average time: 3 sec

Time taken on solution 3:

$ time nova usage --tenant afe3257305514254a4ae6c451bb23804
Usage from 2017-08-15 to 2017-09-13:
+---------+--------------+-----------+---------------+
| Servers | RAM MB-Hours | CPU Hours | Disk GB-Hours |
+---------+--------------+-----------+---------------+
| 1000 | 632.89 | 1.24 | 0.00 |
+---------+--------------+-----------+---------------+

real 0m3.324s
user 0m1.680s
sys 0m0.092s

$ time nova usage --tenant afe3257305514254a4ae6c451bb23804
Usage from 2017-08-15 to 2017-09-13:
+---------+--------------+-----------+---------------+
| Servers | RAM MB-Hours | CPU Hours | Disk GB-Hours |
+---------+--------------+-----------+---------------+
| 1000 | 632.89 | 1.24 | 0.00 |
+---------+--------------+-----------+---------------+

real 0m3.276s
user 0m1.612s
sys 0m0.164s

$ time nova usage --tenant afe3257305514254a4ae6c451bb23804
Usage from 2017-08-15 to 2017-09-13:
+---------+--------------+-----------+---------------+
| Servers | RAM MB-Hours | CPU Hours | Disk GB-Hours |
+---------+--------------+-----------+---------------+
| 1000 | 632.89 | 1.24 | 0.00 |
+---------+--------------+-----------+---------------+

real 0m3.394s
user 0m1.688s
sys 0m0.120s

Average time: 3 sec

So from above results it seems that same time is required to get instances usages on both current master and solution 3.

Needs others opinion about this.