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

The Couch DB adapter should use a Shared Worker for the _changes feed #3880

Closed
akhenry opened this issue May 19, 2021 · 5 comments · Fixed by #3993
Closed

The Couch DB adapter should use a Shared Worker for the _changes feed #3880

akhenry opened this issue May 19, 2021 · 5 comments · Fixed by #3993
Assignees

Comments

@akhenry
Copy link
Contributor

akhenry commented May 19, 2021

The number of simultaneous HTTP connections is limited to six connections per browser and domain, ie. not per-tab. The Couch DB adapter is currently holding open an HTTP connection, using up one connection, and reducing the number of available connections for everything else to five.

To make matters worse, opening a second tab will hold open a second connection, and so on. Six tabs will use up all available connections to the domain, and hold them open, blocking any other requests.

HTTP/2 would help in this situation, but it is not a good general solution.

A reasonable general solution is to use a dedicated Shared Worker for the _changes feed, which all of the tabs can connect to and receive change events from. This will still reduce our connection pool to five simultaneous connections, but unless Couch DB decide to use WebSockets for the _changes feed I don't see that we have much choice here.

The use of shared workers will mean that the changes feed will not be supported in Safari until they reinstate support for Shared Workers.

@akhenry
Copy link
Contributor Author

akhenry commented May 19, 2021

Should consider implementing Server Side Events at the same time - #3881

@shefalijoshi
Copy link
Contributor

shefalijoshi commented Jul 2, 2021

I've noticed that when running on a local machine, Open MCT cannot be opened in more than 5 tabs even when LocalStorage is being used (instead of CouchDB) because of how webpack works.
We need a different solution for this.

There is no problem opening more than 5 tabs when NOT running locally.

The SharedWorker solution for the changes feed is a good performance improvement regardless of the tabs issue.

@shefalijoshi
Copy link
Contributor

shefalijoshi commented Aug 3, 2021

Testing instructions:
On Firefox, Chrome

  1. Start Open MCT in multiple tabs In each tab you should not see any network requests with this in the URL: "_changes?feed=continuous&style=main_only&heartbeat=50000&filter=_selector"
    NOTE: On CHROME you can go to chrome://inspect/#workers to see the shared worker (node_modules/openmct/dist/couchDBChangesFeed.js)
    : On Firefox you can go to about:debugging#/runtime/this-firefox to see the shared worker (node_modules/openmct/dist/couchDBChangesFeed.js)
  2. View the same plan or notebook in each tab.
  3. Change the plan or notebook and ensure that all the views are updated.

On Safari - Start Open MCT in multiple tabs In each tab you should see network requests with this in the URL: "_changes?feed=continuous&style=main_only&heartbeat=50000&filter=_selector" for each tab

@jvigliotta
Copy link
Contributor

Verified - Testathon - 8/5/2021

@akhenry
Copy link
Contributor Author

akhenry commented Aug 5, 2021

Verified fixed

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

Successfully merging a pull request may close this issue.

4 participants