Bug 1328627

Summary: as the number of subs increases, dashboard page gets slower
Product: Red Hat Satellite Reporter: Chris Duryee <cduryee>
Component: PerformanceAssignee: Chris Duryee <cduryee>
Status: CLOSED ERRATA QA Contact: Lukas Zapletal <lzap>
Severity: high Docs Contact:
Priority: high    
Version: 6.2.0CC: bbuckingham, dmoessne, lzap, mmccune, rplevka, sthirugn
Target Milestone: UnspecifiedKeywords: Regression, Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
URL: http://projects.theforeman.org/issues/14723
Whiteboard:
Fixed In Version: rubygem-katello-3.0.0.31-1,rubygem-katello-3.0.0.31-1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-07-27 11:41:54 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:
Attachments:
Description Flags
Dashboard works fine none

Description Chris Duryee 2016-04-19 22:05:04 UTC
Description of problem:

As the number of subscriptions increase, the "current subscription status" widget on the dashboard gets slower to load. It makes 1-2 calls to candlepin per subscription. Ideally the page would take 3-4 seconds to load, no matter how many subscriptions are in the loaded manifest.

An alternative way to populate the widget would be to call candlepin to get all of the pools for the org at once, and then loop over that to build the data. That would avoid the number of candlepin calls scaling as the number of subs increases.

Version-Release number of selected component (if applicable): 6.2.0 beta 8

Comment 2 Chris Duryee 2016-04-25 13:27:34 UTC
WORKAROUND NOTE: if the dashboard page is slow, one workaround is to remove the "current subscription status" widget.

Comment 3 Roman Plevka 2016-05-10 15:03:35 UTC
This gets really intense with 'Any Context' set for Organization.
Loading the dashboard also blocks switching the context.

Comment 4 Chris Duryee 2016-05-10 18:47:57 UTC
The upstream patch should save some time off of the dashboard. However if you have many, many orgs, it will still be somewhat slow. At best, we need to make one call to candlepin per org to find the number of active pools for each org.

Comment 5 Bryan Kearney 2016-05-11 14:15:54 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/14723 has been closed

Comment 6 Lukas Zapletal 2016-06-22 08:34:09 UTC
Verified on snap 15:

[root@tyan-gt24-03 ~]# rpm -q satellite katello foreman
satellite-6.2.0-15.1.beta.el7sat.noarch
katello-3.0.0-8.el7sat.noarch
foreman-1.11.0.38-1.el7sat.noarch

[root@tyan-gt24-03 ~]# grep reduce /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.0.0.49/app/views/dashboard/_subscription_status_widget.html.erb
<% total_active_subscriptions = organizations.map {|org| org.active_pools_count}.reduce(:+) %>

Instead of subscriptions-all call, there is now get of /candlepin/owners/MyOrg/pools?attribute=unmapped_guests_only:!true

I am not measuring how much faster this is, the key here is it works as expected and dashboard works fine (attaching PNG image).

2016-06-22 04:30:24,325 [thread=http-bio-8443-exec-2] [req=7139e66b-6bda-410a-94a8-4aab0a0498f8, org=] INFO  org.candlepin.common.filter.LoggingFilter - Request: verb=GET, uri=/candlepin/owners/MyOrg/info
2016-06-22 04:30:24,580 [thread=http-bio-8443-exec-2] [req=7139e66b-6bda-410a-94a8-4aab0a0498f8, org=MyOrg] INFO  org.candlepin.common.filter.LoggingFilter - Response: status=200, content-type="application/json", time=255
2016-06-22 04:30:24,630 [thread=http-bio-8443-exec-9] [req=f961e147-04bb-4e8e-9498-36c07df3cfc5, org=] INFO  org.candlepin.common.filter.LoggingFilter - Request: verb=GET, uri=/candlepin/owners/MyOrg/pools?attribute=unmapped_guests_only:!true
2016-06-22 04:30:24,923 [thread=http-bio-8443-exec-9] [req=f961e147-04bb-4e8e-9498-36c07df3cfc5, org=MyOrg] INFO  org.candlepin.common.filter.LoggingFilter - Response: status=200, content-type="application/json", time=294

Comment 7 Lukas Zapletal 2016-06-22 08:34:35 UTC
Created attachment 1170635 [details]
Dashboard works fine

Comment 8 Bryan Kearney 2016-07-27 11:41:54 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-2016:1501