Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use single https session to retrieve all rock-on definitions #2707

Closed
phillxnet opened this issue Oct 17, 2023 · 5 comments
Closed

Use single https session to retrieve all rock-on definitions #2707

phillxnet opened this issue Oct 17, 2023 · 5 comments
Assignees

Comments

@phillxnet
Copy link
Member

Whenever we populate/update available rock-ons we first retrieve root.json, then parse this file and create a new https session to retrieve each individual json Rock-on definition file listed within root.json. The vast majority of the time taken in retrieving each Rock-on definition is spent in the session setup itself. I.e. with our 70+ Rock-ons we need to create 71+ https sessions.

It is proposed that we consider instead maintaining our initial root.json retrieval session, useful to establish if a connection is even possible, then attempt to retrieve all actual definition files over a follow-up session. Where our expected time saving will be 70+ fold on individual sessions.

I.e. To retrieve a large Rock-on definition (3.9KB) via a Web-browser is as follows:
'''
Started at 6.60 ms
Resource Scheduling DURATION
Queueing

6.60 ms
Connection Start DURATION
Stalled

0.51 ms
DNS Lookup

16 μs
Initial connection

159.28 ms
SSL

74.30 ms
Request/Response DURATION
Request sent

0.13 ms
Waiting for server response

72.87 ms
Content Download

0.91 ms
Explanation 240.41 ms

@phillxnet phillxnet self-assigned this Oct 17, 2023
@phillxnet
Copy link
Member Author

phillxnet commented Oct 17, 2023

I'll have a little experiment with this as having first considered server side compression, I think we would be far better off looking to http session refinements, give he actual download is one of the smallest time sinks. Plus we would inevitably incur decompression time on the client: especially on lower power devices.

@phillxnet
Copy link
Member Author

Notes re timings:

With single session:

  • 127.0.0.1 - - [17/Oct/2023:14:19:39 +0100] "POST /api/rockons/update HTTP/1.0" 200 0 "https://lbuildvm.lan/home" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0" 9558ms
  • 127.0.0.1 - - [17/Oct/2023:14:21:44 +0100] "POST /api/rockons/update HTTP/1.0" 200 0 "https://lbuildvm.lan/home" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0" 9594ms
  • 127.0.0.1 - - [17/Oct/2023:14:22:16 +0100] "POST /api/rockons/update HTTP/1.0" 200 0 "https://lbuildvm.lan/home" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0" 9658ms

Removing proposed session manager:

  • 127.0.0.1 - - [17/Oct/2023:14:25:54 +0100] "POST /api/rockons/update HTTP/1.0" 200 0 "https://lbuildvm.lan/home" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0" 22435ms
  • 127.0.0.1 - - [17/Oct/2023:14:26:37 +0100] "POST /api/rockons/update HTTP/1.0" 200 0 "https://lbuildvm.lan/home" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0" 22599ms
  • 127.0.0.1 - - [17/Oct/2023:14:27:18 +0100] "POST /api/rockons/update HTTP/1.0" 200 0 "https://lbuildvm.lan/home" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0" 22676ms

From the above experimental change, which just wraps our Rock-on definition files retrieval in a requests.Session() manager, we look to have a significant speed-up, taking a little less than half the time to achieve the same number of gets.
-With single session: 9.6 seconds
-With individual sessions: 22.6 seconds.

Looking into better logging of just the retrieval to see the real difference.

@phillxnet
Copy link
Member Author

More focused timing experiment but still including the initial parsing to a single dictionary:

Before proposal

I.e. https session for each json:

  • [17/Oct/2023 14:54:52] INFO [storageadmin.views.rockon:505] Rock-on definitions retrieved in: 19.1876 seconds
  • [17/Oct/2023 14:55:27] INFO [storageadmin.views.rockon:505] Rock-on definitions retrieved in: 19.1901 seconds
  • [17/Oct/2023 14:55:59] INFO [storageadmin.views.rockon:505] Rock-on definitions retrieved in: 19.3130 seconds

After proposal

To retrieve all definitions under the same https session:

  • [17/Oct/2023 15:00:43] INFO [storageadmin.views.rockon:505] Rock-on definitions retrieved in: 6.3684 seconds
  • [17/Oct/2023 15:01:07] INFO [storageadmin.views.rockon:505] Rock-on definitions retrieved in: 6.3027 seconds
  • [17/Oct/2023 15:01:33] INFO [storageadmin.views.rockon:505] Rock-on definitions retrieved in: 6.3330 seconds

We take: (6.33/19.23) = 0.33 around a third of the time.

phillxnet added a commit to phillxnet/rockstor-core that referenced this issue Oct 17, 2023
…#2707

By sharing a single https session, instantiated on the first GET,
we avoid major cumulative delays and reduce client/server resource
overhead. Note that we still employ a dedicated https session to
retrieve our 'index' file of 'root.json'.

## Includes
- Minor fstring adoption in modified area of code.
- Info log of definitions retrieval and initial parsing time.
Intended as a diagnostic aid, and to assist with field
feedback on this process of indeterminate duration.
- Individual file retrieval timeout reduced to 5 seconds.
phillxnet added a commit that referenced this issue Oct 17, 2023
…-to-retrieve-all-rock-on-definitions

Use single https session to retrieve all rock-on definitions #2707
@phillxnet
Copy link
Member Author

Closing as:
Fixed by #2708

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant