livepeer / livepeer/studio

Bandwidth limiting

Open
#187 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
88
Forks
37
PR merge metrics
No merged PRs in 30d

Description

**What's the problem? (required)**
We want to be able to limit bandwidth used by API users.

**Proposed implementation**
Mist allows to configure webhook that will be triggered when stream exceed some threshold -
we can use that to implement configurable system for limiting bandwidth.

Bandwidth could be constrained per stream and per user (say, we have constrain of 10Mb per stream and 50Mb per user - that means that user will not be able to simultaneously transcode more than 5 streams).
There will be global limit that can be overridden per user.

API changes:
add global object
`/globalConfig`
```js
{
bandwithLimit: {
stream: number, // bytes per second
user: number // bytes per second
}
}
```

Also field `bandwithLimit` with the same structure could optionally be added to user object.
API endpoint `/api/stream/key/:streamKey` which is used by mist-api-connector to retrieve
stream's information will also return `bandwithLimit` inside stream object. First it will
look for `bandwithLimit` in the user's object, and if not set then will return `bandwithLimit`
from the `globalConfig` object. mist-api-connector will use that information to stop streams
that exceed specified threshold.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the /globalConfig and /api/stream/key/:streamKey endpoints, along with the user and stream objects described in the issue. Review how mist-api-connector consumes stream information. Done means global and per-user bandwidth limits are represented consistently, user values override global values, and the connector can apply the returned thresholds.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, backend-api-design, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.