Jmeter 3.0:JSR223 + Groovy与BeanShell [英] Jmeter 3.0: JSR223+Groovy vs. BeanShell

查看:358
本文介绍了Jmeter 3.0:JSR223 + Groovy与BeanShell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您能帮我了解我在使用JSR223 + Groovy(带有缓存)和BeanShell时的响应时间之间的差异,以及原因是什么

Could you please help me to understand the difference between response times when i am using JSR223+Groovy (with caching) and BeanShell and what a reason of it:

灰线是JSR223,红色-BeanShell

The gray line is JSR223, red - BeanShell

其中有一个通过HTTP协议发送Protobuf消息的代码:

Inside them a have a code which sending Protobuf message via HTTP protocol:

byte[] data = protobuf.toByteArray();
String SESSION = vars.get("SESSION");

String url = "http://" + vars.get("SERVER_NAME")+":8080/messages/list";
HttpClient client = new DefaultHttpClient();
////System.out.println(url);
HttpPost post = new HttpPost(url);
HttpEntity entity = new ByteArrayEntity(data);
post.setEntity(entity);
post.setHeader(HttpHeaders.CONTENT_TYPE, "application/x-protobuf");
post.setHeader(HttpHeaders.ACCEPT,"*/*");
post.setHeader(HttpHeaders.ACCEPT_ENCODING,"identity");
post.setHeader(HttpHeaders.CONNECTION,"Keep-Alive");
post.setHeader(HttpHeaders.USER_AGENT,"UnityPlayer/5.0.3p3 (http://unity3d.com) ");


post.setHeader("Cookie", "SESSION="+SESSION);
HttpResponse response=null;
try {
    response = client.execute(post);
} catch (ClientProtocolException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
response.getEntity().writeTo(baos);
byte[] b = baos.toByteArray();

推荐答案

我在Sun Java 1.8上运行的Jmeter v3.0遇到了相同的问题.在我看来,Groovy + JSR223占用大量内存,并加载大量临时对象和元类对象.这大大增加了垃圾收集的开销.我使用G1GC作为GC算法.

I observed the same issue with Jmeter v3.0 running on Sun Java 1.8. In my view, Groovy + JSR223 is memory intensive and loads tons of temporary objects and meta class objects. This increases the garbage collection overhead substantially. I was using G1GC as the GC algorithm.

测试#1:Groovy + JSR223-8个请求/秒是在60%到80%CPU和3GB堆空间消耗的情况下实现的吞吐量

Test #1 : Groovy + JSR223 - 8 requests / sec was the throughput achieved with 60 to 80% CPU and 3GB of heap space consumed

测试2:JSR223 + Java(beanshell实现)-GC开销大大减少,CPU%大约为40%到60%.但是,吞吐量没有提高.我观察到bsh.ForName方法有很多线程锁

Test #2 : JSR223 + java (beanshell implementation) - GC overhead reduced considerably and the CPU % was somewhere around 40 to 60%. However, the throughput didn't improve. I observed plenty of thread locks for the bsh.ForName method

测试#3:普通的beanshell采样器中包含Java代码-这是最好的!吞吐量立即达到了令人难以置信的每秒15000,其中CPU%为100%.但是,开销是由于负载造成的.我将其减少了原始负载的10%,仅用20%的CPU即可轻松达到50 req/sec.

Test #3 : plain beanshell sampler with java code in it - This was the best! The throughput immediately reached an incredible 15000 per sec with CPU% at 100%. However, the overhead was due to the load. I reduced it down by 10% of the original load and it was able to achieved more than 50 req/sec easily with just 20% CPU.

基于上面的实验,我建议使用带有Java代码的纯beanshell采样器,而不要使用JSR223.

Based on the experiement conducted above, I would suggest using plain beanshell sampler with java code in it instead of using JSR223.

这篇关于Jmeter 3.0:JSR223 + Groovy与BeanShell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆