2ndtlmining / Fluxnode

Fluxnode Website
https://fluxnode.app.runonflux.io/
5 stars 6 forks source link

Flux Network Utilisation #36

Closed 2ndtlmining closed 1 year ago

2ndtlmining commented 1 year ago

Problem Description

Like to visually show Utilisation across the Flux network at the given point of time at a refresh. Similar to the data today that counts Total nodes, price, and the count per node tier. Similar today no history is needed and as much as possible trying to stay away from any DB's.

Tracking Metrics

Looking to track 4 metrics

  1. Node Utilisation: % metric. This is the total: (Total nodes - Nodes with 0 apps)/Total nodes %
  2. CPU Utilisation: % metric. (Total benchmark Threads - Total locked cores)/Total Threads
  3. Ram Utilisation : % metric. (Total bench marked Ram - Total locked ram)/ Total bench marked ram
  4. SSD Utilisation: % metric. (Total benchmark SSD - Total locked ram)/Total benchmark SSD

UI & Design Ideas

Looking to make it as visual and fun as possible sticking to the sites existing design. But besides just showing numbers like to make use of visual effects, idea so far is speedo dials or numbers within a circle. At this stage circle is what i had in mind. Colour full is ideal.

image image

image

Happy to have a look to what makes most sense. Also one of the guys mentioned seeing we using React may be look at Framer for React

Technical Data

Total Resource

This should be fairly easy to calculate in two ways:

  1. Either count the total nodes per tier, and then multiply with the Resource specifications per tier. Suspect this will be good from performance perspective.

  2. Stats.runonflux.io: Should be able to count the specifications benchmarked as that will have the true resources. This might take a little longer to calculate but should be what we use. more discussed in API section.

Resource Utilisation

This should be easy with the Stats.runonflux.io and have a look at the locked resources. Example code in the API section.

API If we have more efficient ways by all means but looking at what we already using today. Some ideas around calculating Resource utilisation:

image

Couple things we need to be careful for:

Node Utilisation

This calculation we need to make use of our existing code to count the apps. But in this case we just need to make sure we can the 0 app nodes:

image

Also these nodes will return no locked resources like this:

image

Pseudo Code Examples

Couple example of code to calculate the values we need.

Node Resource Utilisation

const api_url = 'https://stats.runonflux.io/fluxinfo/apps.resources'
  async function getdata() {
    const res = await fetch(api_url);
    const json = await res.json();  
    var sumram  = 0;  
    json.data.map((index)=> { sumram = sumram + (index?.apps?.resources?.appsRamLocked)});
    console.log(sumram/1000000,"Tb");
  }
getdata();

image

Total Resources

Using the same API, but focusing on Ram. In this case the API returns ram in GB and not MB above:

const api_url = 'https://stats.runonflux.io/fluxinfo/benchmark'
  async function getdata() {
    const res = await fetch(api_url);
    const json = await res.json();  
    var sumram  = 0;  
    json.data.map((index)=> { sumram = sumram + (index?.benchmark?.bench?.ram)});
    console.log(sumram/1000,"Tb");
  }
getdata();

image

Node Utilization

To calculate this we can use existing data. Today in the main screen we count total nodes, thus we have the base value to devide to calculate % utilisation, thus calculation will be: Node Utilisation = Utilised nodes/Total nodes

To calculate Utilised nodes:

const api_url = 'https://stats.runonflux.io/fluxinfo/apps.resources'
  async function getdata() {
    const res = await fetch(api_url);
    const json = await res.json();  
    const sumemptynodes = json.data.filter((data) => data.apps.resources.appsRamLocked == 0).length;
    console.log(sumemptynodes);
  }
getdata();

image