Sysbench – Pruebas de Estrés en Linux

Share on facebook
Share on twitter
Share on linkedin
Share on whatsapp
Share on telegram
Share on email

Muchas veces preguntan los clientes acerca del rendimiento hardware de una determinada insfraestructura cuando están pensando en migrar sus servidores a ella.

No hace mucho, tuve que realizar una pruebas de estrés en unos determinados servidores para comprobar la velocidad del hardware y poder comparar ambas infraestructuras.

En mi caso utilicé sysbench.

Analiza el consumo de CPU, Memoria y Red con Prometheus

No obstante, existe un consenso entre los fabricantes de hardware para realizar pruebas de estés con una serie de algoritmos estándar: Standard Performance Evaluation Corporation o SPEC.

El software que utiliza los algoritmos SPEC es de pago pero sysbench es gratuito y ya me valía para realizar una comparativa casera.

Con Sysbench se pueden hacer pruebas de estrés de CPU, memoria, disco, y transacciones OLTP de bases de datos, entre otras.

Tutorial de Sysbench

Instalación de Sysbench

Compilando el paquete

Descargué el código fuente del producto y lo compilé en CentOS 6:

[[email protected] ~]# mkdir sysbench
[[email protected] ~]# cd sysbench

[[email protected] sysbench]# wget http://src.fedoraproject.org/repo/pkgs/sysbench/sysbench-1.0.14.tar.gz/sha512/9030b1f40f6800d85ba4c7bf38041a509769983db4bce82b5cab097a5e4439e1ede5d8933f276779172537c961e6f670680bee106fcac3723ef99f361fdcc4f1/sysbench-1.0.14.tar.gz
--2018-04-27 10:01:19-- http://src.fedoraproject.org/repo/pkgs/sysbench/sysbench-1.0.14.tar.gz/sha512/9030b1f40f6800d85ba4c7bf38041a509769983db4bce82b5cab097a5e4439e1ede5d8933f276779172537c961e6f670680bee106fcac3723ef99f361fdcc4f1/sysbench-1.0.14.tar.gz
Resolving src.fedoraproject.org (src.fedoraproject.org)... 209.132.181.16, 209.132.181.15
Connecting to src.fedoraproject.org (src.fedoraproject.org)|209.132.181.16|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11744 (11K) [text/html]
Saving to: ‘sysbench-1.0.14.tar.gz’

100%[=============================================>] 11,744 --.-K/s in 0s

2018-04-27 10:01:25 (40.9 MB/s) - ‘sysbench-1.0.14.tar.gz’ saved [11744/11744]

[[email protected] sysbench]#

[[email protected] sysbench]# ll
total 1472
-rwxrwxrwx 1 root root 1507008 Apr 27 10:02 sysbench-1.0.14.tar.gz
[[email protected] sysbench]#
[[email protected] sysbench]# tar xvzf sysbench-1.0.14.tar.gz
[[email protected] sysbench]# cd sysbench-1.0.14/
[[email protected] sysbench]# ./autogen.sh
[[email protected] sysbench]# ./configure
[[email protected] sysbench]# make
[[email protected] sysbench]# make install
[[email protected] sysbench-1.0.14]# whereis sysbench
sysbench: /usr/local/bin/sysbench
[[email protected] sysbench-1.0.14]#

Descargándolo de un repositorio alternativo

En este caso, lo he descargado en un Linux CentOS 8.

dnf install -y https://repo.percona.com/yum/release/8/RPMS/x86_64/sysbench-1.0.17-3.el8.x86_64.rpm

Ejecución de las pruebas de estrés con Sysbench

Estresando la CPU con un thread (num-threads=1)

[[email protected] ~]# /usr/local/bin/sysbench --test=cpu --cpu-max-prime=20000 --num-threads=1 run
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.14 (using bundled LuaJIT 2.1.0-beta2)

Running the test with following options:
Number of threads: 1
Initializing random number generator from current time

Prime numbers limit: 20000

Initializing worker threads...

Threads started!

CPU speed:
events per second: 267.66

General statistics:
total time: 10.0030s
total number of events: 2678

Latency (ms):
min: 3.15
avg: 3.73
max: 11.31
95th percentile: 4.33
sum: 9990.94

Threads fairness:
events (avg/stddev): 2678.0000/0.00
execution time (avg/stddev): 9.9909/0.00

[[email protected] ~]#

En el resultado anterior, fijémenos en el tiempo que ha tardado en completar el test de rendimiento:

total time: 10.0030s

Estresando la memoria

[[email protected] ~]# sysbench --test=memory --num-threads=4 run
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
WARNING: --num-threads is deprecated, use --threads instead
sysbench 1.0.17 (using bundled LuaJIT 2.1.0-beta2)

Running the test with following options:
Number of threads: 4
Initializing random number generator from current time


Running memory speed test with the following options:
  block size: 1KiB
  total size: 102400MiB
  operation: write
  scope: global

Initializing worker threads...

Threads started!

Total operations: 41983526 (4197793.17 per second)

40999.54 MiB transferred (4099.41 MiB/sec)


General statistics:
    total time:                          10.0001s
    total number of events:              41983526

Latency (ms):
         min:                                    0.00
         avg:                                    0.00
         max:                                   89.42
         95th percentile:                        0.00
         sum:                                15923.88

Threads fairness:
    events (avg/stddev):           10495881.5000/70780.45
    execution time (avg/stddev):   3.9810/0.23

[[email protected] ~]# 

Estresando el disco

Para hacer este tutorial voy a probar con un fichero de 3GB pero, si queremos testear un sistema de producción, deberemos probar con ficheros más grandes. 100GB, por ejemplo.

[[email protected] ~]# sysbench --test=fileio --file-total-size=3G prepare
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.17 (using bundled LuaJIT 2.1.0-beta2)

128 files, 24576Kb each, 3072Mb total
Creating files for the test...
Extra file open flags: (none)
Creating file test_file.0
Creating file test_file.1
Creating file test_file.2
Creating file test_file.3
...
Creating file test_file.126
Creating file test_file.127
3221225472 bytes written in 6.36 seconds (483.31 MiB/sec).
[[email protected] ~]# 

[[email protected] ~]# sysbench --test=fileio --file-total-size=3G --file-test-mode=rndrw --max-time=300 --max-requests=0 run
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
WARNING: --max-time is deprecated, use --time instead
sysbench 1.0.17 (using bundled LuaJIT 2.1.0-beta2)

Running the test with following options:
Number of threads: 1
Initializing random number generator from current time


Extra file open flags: (none)
128 files, 24MiB each
3GiB total file size
Block size 16KiB
Number of IO requests: 0
Read/Write ratio for combined random IO test: 1.50
Periodic FSYNC enabled, calling fsync() each 100 requests.
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing random r/w test
Initializing worker threads...

Threads started!


File operations:
    reads/s:                      9365.77
    writes/s:                     6243.85
    fsyncs/s:                     19980.33

Throughput:
    read, MiB/s:                  146.34
    written, MiB/s:               97.56

General statistics:
    total time:                          300.0060s
    total number of events:              10677117

Latency (ms):
         min:                                    0.00
         avg:                                    0.03
         max:                                  132.94
         95th percentile:                        0.07
         sum:                               292935.13

Threads fairness:
    events (avg/stddev):           10677117.0000/0.00
    execution time (avg/stddev):   292.9351/0.00

[[email protected] ~]#

[[email protected] ~]# sysbench --test=fileio --file-total-size=3G cleanup
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.17 (using bundled LuaJIT 2.1.0-beta2)

Removing test files...
[[email protected] ~]# 

Como comentaba anteriormente, sysbench es muy amplio y permite realizar muchos tipos de pruebas de estrés. Mejor os dejo un enlace con detalles de las distintas pruebas y modos de uso:

¿Te ha gustado? ¡Compártelo!

Share on facebook
Share on twitter
Share on linkedin
Share on whatsapp
Share on telegram
Share on email

SUSCRÍBETE A PUERTO53

Recibe un email periódico con los artículos más interesantes de Puerto53.com

Antes de suscribirte lee los términos y condiciones. Gracias.

Contenido Relacionado

Artículos Recientes

Deja un comentario

About Author