Bug 1656371

Summary: API requests with attributes work slow
Product: Red Hat CloudForms Management Engine Reporter: abekasau
Component: PerformanceAssignee: Nick LaMuro <nlamuro>
Status: CLOSED ERRATA QA Contact: Parthvi Vala <pvala>
Severity: medium Docs Contact: Red Hat CloudForms Documentation <cloudforms-docs>
Priority: medium    
Version: unspecifiedCC: abekasau, dmetzger, jocarter, kbrock, nlamuro, obarenbo, pvala, simaishi
Target Milestone: GAKeywords: Performance
Target Release: 5.11.0   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 5.11.0.2 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-12-12 13:34:53 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: CFME Core Target Upstream Version:
Embargoed:

Description abekasau 2018-12-05 11:07:51 UTC
Description of problem:

Commit below highly slows down performance of API requests with attributes

https://github.com/ManageIQ/manageiq-api/commit/1845785bf7c3d7019df3c8002cff4c0cb9d33d36#diff-00bf332c6d31e69fa897ff19cd3e0bc5

E. g.:

This request is used by ui-service

api/services?expand=resources&limit=20&offset=0&attributes=picture%2Cpicture.image_href%2Cchargeback_report%2Cevm_owner.userid%2Cv_total_vms%2Cpower_state%2Call_service_children%2Ctags&filter[]=ancestry%3Dnull&sort_by=created_at&sort_options=&sort_order=desc

Rbac is called for each attribute for each service
8 attributes * 20 services (default limit is 20) = 160 rbac calls

Version-Release number of selected component (if applicable):
manageiq gaprinashvili


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 3 Keenan Brock 2018-12-13 03:22:57 UTC
Even before the rbac was added, this report was also quite query intensive.
It has to do access of vms from services/service templates.


Looking into ways to reduce the number of queries.
We've had a number of attempts here in the past, so it may be difficult to get much improvement
Still looking into this

Comment 4 Keenan Brock 2019-01-03 18:08:14 UTC
Still looking at this.

Trying to find a way that each collection running through rbac does not cause multiple database queries.

Comment 11 Parthvi Vala 2019-06-14 14:45:54 UTC
FIXED. Verified on 5.11.0.8.

Query: 
GET api/services?expand=resources&limit=20&offset=0&attributes=picture%2Cpicture.image_href%2Cchargeback_report%2Cevm_owner.userid%2Cv_total_vms%2Cpower_state%2Call_service_children%2Ctags&filter[]=ancestry%3Dnull&sort_by=created_at&sort_options=&sort_order=desc

Of total 30 services, the request took about 4.32sec on 5.10.6 and 2.3sec on 5.11.0.8.

Comment 15 errata-xmlrpc 2019-12-12 13:34:53 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2019:4199