Make server.js
delete old peer connections on the same IP
#118
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before this PR,
server.js
created a new peer connection for every new registered publisher/subscriber. This was intentional, to allow multiple devices to simultaneously register to the robot's video stream (e.g., to test latency). However, this also means that throughout the course of the meal, more and more peer connections are created, which hugely increases the CPU utilization ofserver.js
(we saw it go up to 500%).This PR addresses that by only allowing one publisher and subscriber per topic at a time. (Note: in theory this should allow for a different subscriber per IP, but in practice all the IPs end up being the same -- unclear why -- resulting in this only allowing one publisher/subscriber per topic at once.)
Testing: On lovelace:
server.js
start_robot_browser.js
several times. Verify that CPU utilization forserver.js
stays roughly the same.server.js
stays roughly the same.