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

Re-use remote transcoders for a stream #1842

Closed
kyriediculous opened this issue Apr 14, 2021 · 3 comments · Fixed by #1849
Closed

Re-use remote transcoders for a stream #1842

kyriediculous opened this issue Apr 14, 2021 · 3 comments · Fixed by #1849

Comments

@kyriediculous
Copy link
Contributor

kyriediculous commented Apr 14, 2021

Abstract

The split orchestrator and transcoder architecture enables the creation of transcoding pools. These pools can either be private or public.

When an orchestrator receives a stream it will currently send each segment for a sessionID to a different transcoder.

Analogous to how a broadcaster sticks with the same orchestrator for all segments of a stream as long as it can transcode in real-time, an orchestrator should stick with the same transcoder for a stream.

Motivation

Sending each segment of a stream to a different transcoder could lead to a degradation of performance:

  • Transcoders can differ in performance (speed, quality, ...)
  • Harder to re-use GPU sessions
  • Fanning out on a per-stream basis can negatively impact work retention

Proposed Solution

Current Flow

  1. Segment comes in

  2. The list of connected RemoteTranscoders is sorted by load

    Each segment in flight for a RemoteTranscoder increments load by 1

  3. Select the head of the sorted RemoteTranscoder list

    If the RemoteTranscoder is no longer connected, discard it and continue

  4. Send segment to RemoteTranscoder

  5. Decrement load for RemoteTranscoder upon return

Since ordering of the RemoteTranscoder list is not guaranteed at any point in time selection is entirely random.

Proposed Flow

  1. New segment comes in for stream with sessionID

  2. Check if there is a RemoteTranscoder assigned to sessionID

    • No assignment - proceed to step 3
    • Transcoder assigned - proceed to step 4
  3. The list of connected RemoteTranscoders is sorted by load, select the head of the list and increment its load.

    load and capacity will be defined on a per-stream basis rather than a per-segment basis. Each stream session for a RemoteTranscoder increments load by 1

  4. Check whether the (newly) assigned RemoteTranscoder is still connected

    • connected - proceed to step 5
    • not connected - go back to step 3

    If the RemoteTranscoder is no longer connected, remove it from the list, remove it from the assignment and decrement its load

  5. Update RemoteTranscoderManager state to reflect the assigned RemoteTranscoder for sessionID (if necessary)

  6. Send segment to RemoteTranscoder

    • success: no-op
    • error: remove it from the list, remove it from the assignment and decrement its load

Implementation Tasks and Considerations

One potential way of implementing this could be as follows:

Add a map to the RemoteTranscoderManager to keep track of the assigned RemoteTranscoder for an sessionID.

type RemoteTranscoderManager struct {
    ...
    StreamSessions: map[sessionID]*RemoteTranscoder
}

RemoteTranscoderManager.selectTranscoder() can be updated to take a sessionID as argument.

func(rtm *RemoteTranscoderManager) selectTranscoder(string sessionID) *RemoteTranscoder {
    rt, ok := rtm.StreamSessions[sessionID]
    if !ok {
        // ... current selection logic
        currentTranscoder.load++
        sort.Sort(byLoadFactor(rtm.remoteTranscoders))
        // Assign currentTranscoder
        rt = currentTranscoder
	}
    }
    
    return rt
}

RemoteTranscoder.completeTranscoder() would also have to take sessionID as an argument and be tied to the transcode session cleanup loop, or a separate cleanup loop.

Testing Tasks and Considerations

  • A transcoder should be re-used for a stream with sessionID as long as no error or timeout occurs.
reubenr0d added a commit to reubenr0d/go-livepeer that referenced this issue Apr 21, 2021
reubenr0d pushed a commit to reubenr0d/go-livepeer that referenced this issue Apr 21, 2021
reubenr0d pushed a commit to reubenr0d/go-livepeer that referenced this issue Apr 21, 2021
reubenr0d pushed a commit to reubenr0d/go-livepeer that referenced this issue Apr 21, 2021
reubenr0d pushed a commit to reubenr0d/go-livepeer that referenced this issue Apr 22, 2021
reubenr0d pushed a commit to reubenr0d/go-livepeer that referenced this issue Apr 22, 2021
* Adds better error handling
reubenr0d pushed a commit to reubenr0d/go-livepeer that referenced this issue Apr 25, 2021
* Test cases
* Session close fixes
* Changed RTmutex pointer to var
reubenr0d pushed a commit to reubenr0d/go-livepeer that referenced this issue Apr 25, 2021
reubenr0d pushed a commit to reubenr0d/go-livepeer that referenced this issue Apr 25, 2021
reubenr0d pushed a commit to reubenr0d/go-livepeer that referenced this issue Apr 25, 2021
reubenr0d pushed a commit to reubenr0d/go-livepeer that referenced this issue Apr 25, 2021
reubenr0d pushed a commit to reubenr0d/go-livepeer that referenced this issue Apr 25, 2021
reubenr0d pushed a commit to reubenr0d/go-livepeer that referenced this issue Apr 25, 2021
reubenr0d pushed a commit to reubenr0d/go-livepeer that referenced this issue Apr 25, 2021
reubenr0d pushed a commit to reubenr0d/go-livepeer that referenced this issue Apr 25, 2021
reubenr0d pushed a commit to reubenr0d/go-livepeer that referenced this issue Apr 27, 2021
@gitcoinbot
Copy link

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


This issue now has a funding of 0.35 ETH (921.26 USD @ $2632.18/ETH) attached to it.

@gitcoinbot
Copy link

gitcoinbot commented Apr 28, 2021

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work has been started.

These users each claimed they can complete the work by 265 years, 6 months from now.
Please review their action plans below:

1) reubenr0d has been approved to start work.

Work for this almost complete, just left with some minor changes.

Learn more on the Gitcoin Issue Details page.

reubenr0d pushed a commit to reubenr0d/go-livepeer that referenced this issue Apr 28, 2021
reubenr0d pushed a commit to reubenr0d/go-livepeer that referenced this issue Apr 28, 2021
@kyriediculous kyriediculous self-assigned this Apr 28, 2021
@gitcoinbot
Copy link

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work for 0.35 ETH (1182.52 USD @ $3378.63/ETH) has been submitted by:


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.

2 participants