Memory usage by group of processes

While monitoring a http/php server, I needed to do some statistics about php-cgi memory usage.

Playing with memory_limit in PHP, we wanted to know the average memory usage per php-cgi process. This is easily calculated with our best friend awk.

First, get the number of php running processes:

# ps aux | grep php-cgi | grep -v grep | wc -l
126

Then, use awk to calculate the average memory usage for these processes:

# ps aux | grep --exclude=grep php-cgi | grep -v grep | awk 'BEGIN{s=0;}{s=s+$6;}END{print s/126;}'
33987.8

The number used in the calculation is the field RSS given by ps. The ps manual page says:

rss: resident set size, the non-swapped physical memory that a task has used (in kiloBytes)

You can also calculate the total memory used by all php-cgi processes:

# ps aux | grep --exclude=grep php-cgi | grep -v grep | awk 'BEGIN{s=0;}{s=s+$6;}END{print s;}'
4302028

If you need to watch the trend of this average memory usage, a little shell loop does the trick:

# while [ 1 ]; do ps aux | grep --exclude=grep php-cgi | grep -v grep | awk 'BEGIN{s=0;}{s=s+$6;}END{print s/126;}'; sleep 2; done
34401.3
34405.1
34408.4
34409.4
34414.2
34417

This entry was written by CharlyBr, posted on March 13, 2009 at 4:14 pm, filed under Benchmarks, Command line, Monitoring and tagged , , , . Leave a comment or view the discussion at the permalink.

Benchmark disk IOs

While reading this interresting article on benchmarking disks, Benjamin Schweizer pointed out a link to a python tool he wrote: benchmark disks IOs.

I made a try on different available servers.

Server 1

  • PowerEdge 2950 – Intel(R) Xeon(R) CPU 5160  @ 3.00GHz
  • Dell PowerEdge Expandable RAID controller 5 (LSI Logic SAS based MegaRAID driver, PERC 5/i Integrated)
  • 6 disks RAID 10
  • uname -a Linux … 2.6.22.1 #1 SMP Wed Aug 8 11:02:15 CEST 2007 x86_64 GNU/Linux
# python iotest-2008-10-15 /dev/sda4 10
/dev/sda4, 397 GB, 512B blocks: 169.8 IOs/s, 84 kB/s
/dev/sda4, 397 GB, 1024B blocks: 160.7 IOs/s, 160 kB/s
/dev/sda4, 397 GB, 2 kB blocks: 153.2 IOs/s, 306 kB/s
/dev/sda4, 397 GB, 4 kB blocks: 140.2 IOs/s, 560 kB/s
/dev/sda4, 397 GB, 8 kB blocks: 133.0 IOs/s, 1 MB/s
/dev/sda4, 397 GB, 16 kB blocks: 113.2 IOs/s, 1 MB/s
/dev/sda4, 397 GB, 32 kB blocks: 85.7 IOs/s, 2 MB/s
/dev/sda4, 397 GB, 64 kB blocks: 80.0 IOs/s, 4 MB/s
/dev/sda4, 397 GB, 128 kB blocks: 74.2 IOs/s, 9 MB/s
/dev/sda4, 397 GB, 256 kB blocks: 70.9 IOs/s, 17 MB/s
/dev/sda4, 397 GB, 512 kB blocks: 62.3 IOs/s, 31 MB/s
/dev/sda4, 397 GB, 1024 kB blocks: 53.8 IOs/s, 53 MB/s

Server 2

  • PowerEdge 2950 – Intel(R) Xeon(R) CPU 5130  @ 2.00GHz
  • LSI Logic SAS based MegaRAID driver
  • 2 disks RAID 0
  • uname -a: Linux … 2.6.18-5-686 #1 SMP Fri Jun 1 00:47:00 UTC 2007 i686 GNU/Linux
# python iotest-2008-10-15 /dev/sda4 10
/dev/sda4, 220 GB, 512B blocks: 78.7 IOs/s, 39 kB/s
/dev/sda4, 220 GB, 1024B blocks: 76.9 IOs/s, 76 kB/s
/dev/sda4, 220 GB, 2 kB blocks: 77.5 IOs/s, 154 kB/s
/dev/sda4, 220 GB, 4 kB blocks: 77.9 IOs/s, 311 kB/s
/dev/sda4, 220 GB, 8 kB blocks: 76.6 IOs/s, 613 kB/s
/dev/sda4, 220 GB, 16 kB blocks: 75.5 IOs/s, 1 MB/s
/dev/sda4, 220 GB, 32 kB blocks: 73.9 IOs/s, 2 MB/s
/dev/sda4, 220 GB, 64 kB blocks: 68.5 IOs/s, 4 MB/s
/dev/sda4, 220 GB, 128 kB blocks: 58.9 IOs/s, 7 MB/s
/dev/sda4, 220 GB, 256 kB blocks: 44.7 IOs/s, 11 MB/s
/dev/sda4, 220 GB, 512 kB blocks: 33.3 IOs/s, 16 MB/s
/dev/sda4, 220 GB, 1024 kB blocks: 23.4 IOs/s, 23 MB/s

Server 3

  • PowerEdge 1950
  • Intel(R) Xeon(R) CPU E5410  @ 2.33GHz
  • LSI Logic / Symbios Logic – SAS1078 PCI-X Fusion-MPT SAS
  • 2 disks RAID 1
  • uname -a: Linux … 2.6.18-6-686 #1 SMP Tue Jun 17 21:31:27 UTC 2008 i686 GNU/Linux
# python iotest-2008-10-15 /dev/sda4 10
/dev/sda4, 220 GB, 512B blocks: 88.6 IOs/s, 44 kB/s
/dev/sda4, 220 GB, 1024B blocks: 89.6 IOs/s, 89 kB/s
/dev/sda4, 220 GB, 2 kB blocks: 87.7 IOs/s, 175 kB/s
/dev/sda4, 220 GB, 4 kB blocks: 86.4 IOs/s, 345 kB/s
/dev/sda4, 220 GB, 8 kB blocks: 86.4 IOs/s, 690 kB/s
/dev/sda4, 220 GB, 16 kB blocks: 83.6 IOs/s, 1 MB/s
/dev/sda4, 220 GB, 32 kB blocks: 79.9 IOs/s, 2 MB/s
/dev/sda4, 220 GB, 64 kB blocks: 71.9 IOs/s, 4 MB/s
/dev/sda4, 220 GB, 128 kB blocks: 59.2 IOs/s, 7 MB/s
/dev/sda4, 220 GB, 256 kB blocks: 54.2 IOs/s, 13 MB/s
/dev/sda4, 220 GB, 512 kB blocks: 34.6 IOs/s, 17 MB/s
/dev/sda4, 220 GB, 1024 kB blocks: 22.1 IOs/s, 22 MB/s

Links

This entry was written by CharlyBr, posted on October 21, 2008 at 2:17 pm, filed under Benchmarks and tagged , , . Leave a comment or view the discussion at the permalink.