2ndtlmining / Fluxnode

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

[Feature #36] Add new APIs for benchmarks of Flux nodes, calculate the percentages and show up #58

Closed Hiroshi97 closed 1 year ago

Hiroshi97 commented 1 year ago

Resolve #36

2ndtlmining commented 1 year ago

@Hiroshi97 This is amazing! Love the colours.

image

Couple small things, not sure if you want me to merge as is or wait a bit but what i spotted if it is possible to change:

image Should be something more or less like this (apologies, tried doing a clone and PR on your branch but some reason i cant or i am just a noob :) ):

image

SSD doesnt look right, but think its just a copy and paste, and i need to do the node count also but thats the idea

Thus if we look at the node utilization as example, which is about 40%, should be like

something to that tune?

Hiroshi97 commented 1 year ago

@2ndtlmining Hi, I've updated the code. Please check and let I know if I'm still missing anything. Thanks!

2ndtlmining commented 1 year ago

@Hiroshi97 Thanks again, starting to look great. Just a couple things, but again i apologies i am explaining like my backside :)

  1. Node utilisation. Think we got it the wrong way around: image

What i am thinking is this more or less (not sexy at all and my bad attempt):

image

const api_url = 'https://stats.runonflux.io/fluxinfo/apps.resources' async function getdata() { const totalnodes = 15292; // we get this from our original API to count total nodes 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("Emptynodes= "+ sumemptynodes); const utilized = ((totalnodes - sumemptynodes)/totalnodes) * 100; console.log("Node Utilization= "+ utilized + " %"); } getdata();

  1. CPU, Ram and SSD not calculating for some reason:

image

What i was thinking is something like this for Ram, but for all 3 just with the different API data element (again not sexy):

image

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

const api_url = 'https://stats.runonflux.io/fluxinfo/benchmark' async function gettotaldata() { 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("Total Ram = " + sumram/1000,"Tb"); }

getdatautilised(); gettotaldata(); //Percentage is just these two devided Utilized / Total

  1. Data loading: Noticed that nothing is loading at all until a wallet is put in. Was wondering if we can still do it as part of the Gstore load or the main set, but just load the data as it comes available. Almost similar to what we have done with the Node Overview, data loads in as its available. What happens now is nothing loads until everything is in. But not sure what is possible. But if not possible totally undertstand.
  2. Tooltips: You are the man thank you soo much! Wondering if we can add the naming at the back, like "vCores", "TB", "TB"

Sorry hopefully i am not too much of a pain

Hiroshi97 commented 1 year ago
  1. Fixed
  2. The calcs are still correct I believe. The total should have not been calculated due to the failed response from API. Since the utilized resources and the total resources are calculated by different APIs, so the API for total resources might be failed in your screenshot meanwhile the utilized resources are still calculated, which also affected the percentage at all (all = 0).
  3. My bad, didn't check the empty wallet case
  4. Updated

However, I'm still confused why we are using utilized RAM to calculate utilized SSD

  1. SSD Utilisation: % metric. (Total benchmark SSD - Total locked ram)/Total benchmark SSD
2ndtlmining commented 1 year ago

Hey @Hiroshi97

Thanks a lot. Really really apologies. Think i am confusing you. Your 100% spot on. Should use the correct dataset for the data :) Thus Cores for cores, Ram for Ram and SSD for SSD. I just used the Ram as an example to extract the data. Sorry didnt meen we need to take the Ram for the SSD also :)

Looking at the changes you made its fantastic.

image

For SSD we should be using something like this:

image

Looking at the actual API data we getting back from Benchmark and Locked resources looks to be setup in Gb's, so at least its the same. Also i know it says Hdd, but i am 100% sure its SSD requirement. my crappy code:

`const api_urlutil = 'https://stats.runonflux.io/fluxinfo/apps.resources' async function getdatautilised() { const res = await fetch(api_urlutil); const json = await res.json();
var sumssd = 0;
json.data.map((index)=> { sumssd= sumssd + (index?.apps?.resources?.appsHddLocked)}); console.log("Utilized SSD = "+ sumssd/1000," Tb"); // This data looks to be in Gb }

const api_url = 'https://stats.runonflux.io/fluxinfo/benchmark' async function gettotaldata() { const res = await fetch(api_url); const json = await res.json();
var sumtssd = 0;
json.data.map((index)=> { sumtssd = sumtssd + (index?.benchmark?.bench?.ssd)}); console.log("Total SSD = " + sumtssd/1000,"Tb"); //This api data looks to be in Gb }

getdatautilised(); gettotaldata(); //Percentage is just these two devided Utilized / Total `

2ndtlmining commented 1 year ago

Btw i did log a ticket with the team. The Stats API very inconsistent for me. Would think same for you

image

I get the same response every now and again on the benchmarks:

https://stats.runonflux.io/fluxinfo/benchmark

Not sure what is best way to deal with it if it comes. My thinking was just to put 0 or something like NAN or NA = Not available. Thinking longer term may be better to do our internal DB to hit the api and update our table every 30min, think that will increase performance a lot also. But thats for future.

Noticed that the Utilization stats might be loading again when wallet is put it, not sure if thats just a visual thing or if you recon we hitting the API's again? If so think we could save a bit there. Recon we hit it only once on load of the screen and then just do the normal wallet. But might just be my old eye :)

Hiroshi97 commented 1 year ago

@2ndtlmining You're right, the Utilization stats are fetched again when the wallet address is input. The default stats are re-fetched as well but they don't have any transitions so they look like stay the same meanwhile the circular ones have transitions. I've temporarily fixed the re-fetch btw.

About the API issue, yeah thought it was my internet :). I'm going to use both 0 and NA for it

2ndtlmining commented 1 year ago

@Hiroshi97 Man this is fantastic!! Absolutely love it. Looks soo cool:

image

Spotted the SSD utilization, it taking the ram, but thats a small thing, think i can fix that myself also.

Thanks soo much!

2ndtlmining commented 1 year ago

@Hiroshi97 Managed to update the SSD no issue, but noticed, that if we have some data not available in the Utilisation part (thats coming from stats API) it doesnt load any wallet information if a person searches. Almost like it blocks searching. Do you recon there is a way to decouple that?

I havent pushed it to the main site so not really a issue, just have it on the UAT site to play with created #61 just to manage it.

hmm after further testing think its just not loading regardless :) Had a test where it got all the stats api data:

image