Bug 1422304

Summary: host API call for specific host takes a long time with many hosts registered
Product: Red Hat Satellite Reporter: Chris Duryee <cduryee>
Component: HostsAssignee: Daniel Lobato Garcia <dlobatog>
Status: CLOSED ERRATA QA Contact: Roman Plevka <rplevka>
Severity: high Docs Contact:
Priority: high    
Version: 6.2.7CC: abalakht, bbuckingham, bkearney, dlobatog, egolov, inecas, jcallaha, psuriset, rplevka
Target Milestone: UnspecifiedKeywords: Performance, PrioBumpField, Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: foreman-1.11.0.72-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1426422 (view as bug list) Environment:
Last Closed: 2017-05-01 14:00:07 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1426422    
Attachments:
Description Flags
listing times per 20hpp
none
listing times per 100hpp
none
listing times per 1000hpp none

Description Chris Duryee 2017-02-15 00:49:39 UTC
Description of problem:

If you have a large number of hosts registered (perhaps 40K or more), the following call can take minutes:

/api/v2/hosts/<host>

This only occurs if you are *not* using an admin account.

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


How reproducible: every time


Steps to Reproduce:
1. create non-admin account with permissions to view hosts
2. register a large number of systems. They do not have to be checking in.
3. perform GET on url listed above

Actual results: minutes for GET to return


Expected results:  seconds for GET to return

Comment 2 Satellite Program 2017-02-15 01:04:23 UTC
Upstream bug assigned to dlobatog

Comment 3 Satellite Program 2017-02-15 01:04:25 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/15527 has been resolved.

Comment 6 Satellite Program 2017-02-23 21:11:56 UTC
Please add verifications steps for this bug to help QE verify

Comment 7 Daniel Lobato Garcia 2017-02-27 10:02:31 UTC
To verify, simply try the calls described above on Chris Duryee's comment 4 - https://bugzilla.redhat.com/show_bug.cgi?id=1422304#c4 and measure the before/after times.

Comment 8 Roman Plevka 2017-04-24 16:36:28 UTC
here's some time measurements of host listing with variable per_page argument for a satellite 6.2.9-4 having about 65k hosts registered. The Y axis represents the time taken to get the response:


 00:40 +++--+-+-+--+-+-+--+-+-+--+-+-+--+-+--+-+-+--+-+-+--+-+-+--+-+-+--+**   
       +++  + + +  + + +  + + +  + + +  + +  + + +  + + *****+************++   
 00:35 +-+.............................................*.....*.foo.*******-+   
       ++:  : : :  : : :  : : :  : : :  : :  : :******* :  : : :  : : :  :++   
 00:30 +-+...............................*******.........................+-+   
       ++:  : : :  : : :  : :************ :  : : :  : : :  : : :  : : :  :++   
       ++:  : : :  : : :  *** :  : : :  : :  : : :  : : :  : : :  : : :  :++   
 00:25 +++..............**...............................................+++   
       ++:  : : :  : :**  : : :  : : :  : :  : : :  : : :  : : :  : : :  :++   
 00:20 +++..........**...................................................+++   
       ++:  : : :  * : :  : : :  : : :  : :  : : :  : : :  : : :  : : :  :++   
 00:15 +-+.......**......................................................+-+   
       ++:  : :**  : : :  : : :  : : :  : :  : : :  : : :  : : :  : : :  :++   
 00:10 +-+...**..........................................................+-+   
       ++: ** : :  : : :  : : :  : : :  : :  : : :  : : :  : : :  : : :  :++   
       +*** : : :  : : :  : : :  : : :  : :  : : :  : : :  : : :  : : :  :++   
 00:05 *++...............................................................+++   
       +++  + + +  + + +  + + +  + + +  + +  + + +  + + +  + + +  + + +  +++   
 00:00 +-+--+-+-+--+-+-+--+-+-+--+-+-+--+-+--+-+-+--+-+-+--+-+-+--+-+-+--+-+   
       2 40 6  10 1 1 16 1 2 22 2 2 28 3 32 3 3 38 4 4 44 4 4 50 5 5 56 5 600  
                                     per page                                


 07:00 +-++---+--+---+--+--+---+--+---+--+--+---+--+---+--+--+---+--+---++-+   
       ++ +   +  +   +  +  +   +  +   +  +  +   +  +   +  +  +   +  +   + **   
       ++ :   :  :   :  :  :   :  :   :  :  :   :  :   :  :  : foo *******++   
 06:00 +++..........................................................**...+++   
       ++ :   :  :   :  :  :   :  :   :  :  :   :  :   :  :  :   :**:   : ++   
 05:00 +-+.....................................................***.......+-+   
       ++ :   :  :   :  :  :   :  :   :  :  :   :  :   :  :  **  :  :   : ++   
       ++ :   :  :   :  :  :   :  :   :  :  :   :  :   :  :**:   :  :   : ++   
 04:00 +-+................................................*..............+-+   
       ++ :   :  :   :  :  :   :  :   :  :  :   :  :   :**:  :   :  :   : ++   
 03:00 +-+...........................................***.................+-+   
       ++ :   :  :   :  :  :   :  :   :  :  :   :  **  :  :  :   :  :   : ++   
       ++ :   :  :   :  :  :   :  :   :  :  :   :**:   :  :  :   :  :   : ++   
 02:00 +-+....................................***........................+-+   
       ++ :   :  :   :  :  :   :  :   : ******  :  :   :  :  :   :  :   : ++   
 01:00 +-+.......................*******.................................+-+   
       ++ :   :  : ************** :   :  :  :   :  :   :  :  :   :  :   : ++   
       ************  +  +  +   +  +   +  +  +   +  +   +  +  +   +  +   + ++   
 00:00 +-++---+--+---+--+--+---+--+---+--+--+---+--+---+--+--+---+--+---++-+   
      10 200 30 400 50 60 700 80 900 10 11 120 13 140 15 16 170 18 190 20 2100 
                                     per page                                  


 27:00 +-+---+-----+------+-----+-----+-----+-----+-----+------+-----*---+-+   
       ++    +     +      +     +     +     +     +     +      +    *+*   ++   
 24:00 +-+.....................................................foo.*******-+   
       ++    :     :      :     :     :     :     :     :      :  *  : *  ++   
 21:00 +-+.......................................................*......*+-+   
       ++    :     :      :     :     :     :  ****     :      :*    :   *++   
 18:00 +-+.................................****....*...........*.........+*+   
       ++    :     :      :     :     : *** :     : *   :     *:     :    *+   
 15:00 +-+.........................*****............*........*...........+-*   
       ++    :     :      :    ****   :     :     :  *  :   *  :     :    ++   
 12:00 +-+..................***.......................*....*.............+-+   
       ++    :     :   *****    :     :     :     :    *: *    :     :    ++   
 09:00 +-+........*****................................*.*...............+-+   
       ++    : *** :      :     :     :     :     :     *      :     :    ++   
 06:00 +-+..***..........................................................+-+   
       ++ ** :     :      :     :     :     :     :     :      :     :    ++   
 03:00 +**...............................................................+-+   
       *+    +     +      +     +     +     +     +     +      +     +    ++   
 00:00 +-+---+-----+------+-----+-----+-----+-----+-----+------+-----+---+-+   
      1000  2000  3000   4000  5000  6000  7000  8000  9000  10000 11000 12000 
                                     per page                                  

^ note that the sudden drop in the above chart has been most probably caused by timeout.

Comment 9 Roman Plevka 2017-04-24 16:37:32 UTC
Created attachment 1273649 [details]
listing times per 20hpp

Comment 10 Roman Plevka 2017-04-24 16:38:05 UTC
Created attachment 1273650 [details]
listing times per 100hpp

Comment 11 Roman Plevka 2017-04-24 16:38:35 UTC
Created attachment 1273651 [details]
listing times per 1000hpp

Comment 12 Roman Plevka 2017-04-24 16:42:34 UTC
the xlabel of the first 2 plots got scrumbled-
the first chart contains the range (20,40,60,80,...,600)
the second one contains (100,200,300,...,1200)

Comment 14 errata-xmlrpc 2017-05-01 14:00:07 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-2017:1191