JMeter - falta de memória no linux
Estou tentando executar um teste de carga para um aplicativo. Para isso, estou usando o JMeter (v.2.13) em um Ubuntu Vm com 60GB de RAM e mais do que suficiente CPU. O objetivo é alcançar 10 mil usuários conectados via WebSocket.
No entanto, durante a execução do teste, recebo os seguintes erros no console ssh (em aproximadamente 1.5k a 2.5k usuários simulados)
OpenJDK 64-Bit Server VM warning: Attempt to protect stack guard pages failed.
OpenJDK 64-Bit Server VM warning: Attempt to deallocate stack guard pages failed.
OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00007f20ee653000, 12288, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 12288 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /jmetertests/jm/bin/hs_err_pid1833.log
OpenJDK 64-Bit Server VM warning: Attempt to deallocate stack guard pages failed.
OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00007f2218de8000, 12288, 0) failed; error='Cannot allocate memory' (errno=12)
O arquivo do relatório de erros mencionado é semelhante a este
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 12288 bytes for committing reserved memory.
# Possible reasons:
# The system is out of physical RAM or swap space
# In 32 bit mode, the process size limit was hit
# Possible solutions:
# Reduce memory load on the system
# Increase physical memory or swap space
# Check if swap backing store is full
# Use 64 bit Java on a 64 bit OS
# Decrease Java heap size (-Xmx/-Xms)
# Decrease number of Java threads
# Decrease Java thread stack sizes (-Xss)
# Set larger code cache with -XX:ReservedCodeCacheSize=
# This output file may be truncated or incomplete.
#
# Out of Memory Error (os_linux.cpp:2798), pid=1833, tid=140472285792000
#
# JRE version: OpenJDK Runtime Environment (7.0_75-b13) (build 1.7.0_75-b13)
# Java VM: OpenJDK 64-Bit Server VM (24.75-b04 mixed mode linux-amd64 )
# Derivative: IcedTea 2.5.4
# Distribution: Ubuntu 14.04 LTS, package 7u75-2.5.4-1~trusty1
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
Tentei alocar mais memória modificando o jmeter.sh adicionando a seguinte linha antes de o comando java ser emitido no arquivo .sh:
JVM_ARGS="-Xms5g -Xmx20g -Xss300k"
Eu também tentei definir o_JAVA_OPTIONS
variável de ambiente com o seguinte comando
export _JAVA_OPTIONS="-Xms5g -Xmx20g"
E, finalmente, encontrei este comando em algum tópico SO
sysctl -w vm.max_map_count=500000
otop
O comando fornece as seguintes informações na memória
KiB Mem: 61836576 total, 15163400 used, 46673176 free, 10636 buffers
KiB Swap: 0 total, 0 used, 0 free. 94492 cached Mem
ATUALIZARFYI: Eu não uso nenhum ouvinte no JMeter, exceto o simples gravador de dados. No entanto, erros são gerados, mesmo que eu desative o último ouvinte.
java -Xms40g -version
é bem sucedido - para que eu possa realmente alocar tanta memória
Reduzi o tamanho da pilha usando
-Xss300k
o que ajudou ot pelo menos mudou alguma coisa, pois agora eu recebo uma
Uncaught Exception java.lang.OutOfMemoryError:
unable to create new native thread. See log file for details.
erro. Parece que o número de threads no sistema está esgotado?
Update2conforme solicitado por algum usuário, os resultados ufulimit -a
core file size (blocks, -c) 0
scheduling priority (-e) 0
pending signals (-i) 491456
max locked memory (kbytes, -l) 64
open files (-n) 500000
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
max user processes (-u) 491456
... all other entries are set to 'unlimited'
e o limits.conf contém as seguintes entradas
* hard nofile 900000
* soft nofile 900000
root hard nofile 900000
root soft nofile 900000
Additonally eu configurei othreads-max
sobproc/sys/kernel
para algo ridículo alto e também aumentou o valor deproc/sys/vm/max_map_count
Perdi alguma coisa ou fiz algo errado? Obrigado pela ajuda.