Recent

Author Topic: Use of ram and cpu  (Read 833 times)

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Use of ram and cpu
« on: January 29, 2020, 08:30:06 am »
Hi guys, I have the following problem. I have a web service that I run on multiple machines. Now I would like to create a software that manages the load of connections. To do this I have to understand how to know the amount of free memory and the use of the system's CPU.
Eg: 30% ram used and 15% cpu used. So you know which machine to connect to because it is less used. I need a cross platform solution.
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

Thaddy

  • Hero Member
  • *****
  • Posts: 14197
  • Probably until I exterminate Putin.
Specialize a type, not a var.

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: Use of ram and cpu
« Reply #2 on: January 29, 2020, 04:08:52 pm »
I did some tests for the mac. And I have doubts. Why does it give me a memory usage always higher than 110%? Can anyone help me? I practically simulate the commands

For memory: ps -A -o %mem | awk '{s+=$1} END {print s "%"}'
For cpu: ps -A -o %cpu | awk '{s+=$1} END {print s "%"}'
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11382
  • FPC developer.
Re: Use of ram and cpu
« Reply #3 on: January 29, 2020, 04:21:23 pm »
Some memory is shared between applications? Some might be allocated, but not committed?

"memory use" is a subjective term and a quagmire. Similarly for processors (how to count hyperthreading, processor frequency changes etc) One could argue if such crude numbers help at all.

First start with balanced roundrobin ?

 

TinyPortal © 2005-2018