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

Contract resource usage management #244

Open
sanity opened this issue Aug 14, 2022 · 3 comments
Open

Contract resource usage management #244

sanity opened this issue Aug 14, 2022 · 3 comments
Assignees
Labels
A-networking-ring Area: Ring protocol and ops. C-feature Category: New feature or request C-proposal Category: A proposal seeking feedback E-hard Experience needed to fix/implement: Hard / a lot P-medium Medium priority planned This has been synced to PT for triage

Comments

@sanity
Copy link
Collaborator

sanity commented Aug 14, 2022

Goal

Peers attempt to relay contracts that they’re likely to receive requests for. Relaying means that the peer subscribes to contract updates and can then respond to requests for that contract immediately rather than forwarding the request.

Due to the small world network topology, peers are generally more likely to receive requests for contracts close to them.

Overview

  • Peers track resource usage per-contract
  • Resources include storage, bandwidth, CPU usage, memory
  • Cost computed from resources according to cost function
  • Peers advertise contracts they are relaying to neighbors, who may decide to relay them too

Cost function

A simple cost function that looks at each resource as a proportion of the total available to the peer and takes the maximum of these proportions:

$cost = max(storage_c /storage_t, bandwidth_c/bandwidth_t, cpu_c/cpu_t, memory_c/memory_t)$

  • $resource_c$ = contract resource usage
  • $resource_t$ = total resource availability

Relay decision

The peer's goal is to relay the contracts that maximize $requestRate / cost$, where $requestRate$ is the average number of requests per time interval.

New contracts will have an unknown $requestRate$, for these we use an isotonic regression to estimate the $requestRate$ for a given distance between the peer and the contract, assuming that the rate will be higher for closer contracts.

If the peer is exposed to a contract with an estimated $requestRate / cost$ higher than the worst currently related contract, the new contract replaces the existing one.

Related Issues

  • While this mechanism tracks and managed resource usage per-contract, Peer resource usage balancing #4 describes a parallel mechanism that tracks and manages resource usage per-peer
@sanity sanity added C-feature Category: New feature or request C-proposal Category: A proposal seeking feedback E-hard Experience needed to fix/implement: Hard / a lot P-critical Critical priority A-networking-ring Area: Ring protocol and ops. labels Aug 14, 2022
@sanity sanity self-assigned this Aug 14, 2022
@sanity sanity changed the title How peers decide which contracts to relay Contract resource usage management Sep 2, 2022
@iduartgomez iduartgomez added P-medium Medium priority and removed P-critical Critical priority labels Sep 30, 2022
@iduartgomez
Copy link
Collaborator

Re-prioritized since this involves modifying the network layer which we are not touching now until we have a more solid foundation on the contract API.

@sanity
Copy link
Collaborator Author

sanity commented Oct 23, 2022

Should the total available include the proportion of that resource already used?

If not, then Locutus will be more concerned about resources that are constrained than those that aren't, which seems desirable but may have unintended consequences. It does mean that the requestRate/cost for each contract will need to be periodically recomputed and the contracts re-sorted, but that's probably necessary anyway.

@sanity sanity added the planned This has been synced to PT for triage label Dec 18, 2022
@github-actions
Copy link

Pivotal Tracker story: https://www.pivotaltracker.com/story/show/184058031

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-networking-ring Area: Ring protocol and ops. C-feature Category: New feature or request C-proposal Category: A proposal seeking feedback E-hard Experience needed to fix/implement: Hard / a lot P-medium Medium priority planned This has been synced to PT for triage
Projects
None yet
Development

No branches or pull requests

2 participants