gpt4 book ai didi

运行大量线程时出现 JMeter 问题

转载 作者:行者123 更新时间:2023-12-03 12:17:55 24 4
gpt4 key购买 nike

我正在使用 Apache 的 Jmeter 进行测试,我只是访问我公司网站的一页并增加用户数量直到达到阈值,问题是当我达到大约 3000 个线程时 JMeter 并没有运行所有他们。查看聚合图
它只运行了大约 2,536 个(这个数字有所不同,但始终在此附近)。

部分运行在日志中带有以下异常:

01:16 ERROR - jmeter.JMeter: Uncaught exception: 
java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Unknown Source)
at org.apache.jmeter.threads.ThreadGroup.start(ThreadGroup.java:293)
at org.apache.jmeter.engine.StandardJMeterEngine.startThreadGroup(StandardJMeterEngine.java:476)
at org.apache.jmeter.engine.StandardJMeterEngine.run(StandardJMeterEngine.java:395)
at java.lang.Thread.run(Unknown Source)

这种行为是一致的。此外,有一次 JMeter 在中间崩溃,输出一个文件,内容为:
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 32756 bytes for ChunkPool::allocate
# 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 (allocation.cpp:211), pid=10748, tid=11652
#
# JRE version: 6.0_31-b05
# Java VM: Java HotSpot(TM) Client VM (20.6-b01 mixed mode, sharing windows-x86 )

有任何想法吗?
我尝试在 jmeter.bat 中更改堆大小,但这似乎根本没有帮助。

最佳答案

JVM 根本没有能力 running so many threads .而且即使是这样,JMeter 也会消耗大量 CPU 资源来进行纯粹的上下文切换。换句话说,在某些时候,您不是在对 Web 应用程序进行基准测试,而是对托管 JMeter 的客户端计算机进行基准测试。

你有几个选择:

  • 试验 JVM 选项,例如减少默认-Xss512K到更小的东西
  • 运行 JMeter in a cluster
  • 使用采用完全不同方法的工具,例如 Gatling
  • 关于运行大量线程时出现 JMeter 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14610801/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com