'Jmeter'에 해당되는 글 3건

  1. 2013.03.19 JMeter listener is trustful?
  2. 2013.02.26 JMeter
  3. 2013.02.18 JMeter - Java Request
IT/Q&A2013. 3. 19. 15:49

I did load test using jmeter.

I used two listener. one is "Response Times Over Time", and the other is "Transaction per Second".  Comparing with two listeners, I confused whether or not i know the meaning of these data is. I thought that the more the tps is higher, the more the response time is shorter. right?

But the result of data is contrary to what i thought.. is it correct?



Posted by 억사마
IT/Tool2013. 2. 26. 19:03

제일 첫 소개는 당연히 JMeter Wiki이다.

JMeter 단축키

JMeter csv 파일 읽어 User(thread)마다 가변 파라메터 셋팅하기 (여기)



그럼 실제로 한번 해보도록 하자.

우선, 아래는 JMeter를 사용한 안전성, 신뢰성, 부하, 기능 테스트를 위한 테스트 구성이다.


그리고 각 테스트에 대한 시나리오는 다음과 같다.

 안전성 테스트

 FailOver 테스트 - Single, Multi node failure시에 데이터 유실 무 검증 

 
 Aging 테스트 - 장시간동안 서버 처리 기능 검증 
 확장성 테스트

 기존 서버 구성에서 서버가 추가될 경우 부하 Rebalancing 기능 검증

 
 부하  테스트

 최대 한계에 대한 임계치를 구하고, 로드 밸런싱 기능의 성능 검증 

 
 기능 테스트

 Infinispan의 기본 기능, 그리고 추가 확장 기능 검증

 


그리고 위 테스트를 위한 환경 셋팅을 위한 변수 인자들은 다음과 같다.

JMeter 

 

Request Paramter

 
  


테스트 결과 보고서를 제공하는 JMeter의 기능 중 사용할 것을 정리했다.

 SplineVisualizer

 데이터 전송량을 그래프로 보여준다.

 View Results Tree

 각 요청건 별로 실제 송수신 데이터 보여준다. 

 Response Time Over Time

 응답시간별로 그래프 보여준다.

 Transaction Throughput vs Threads

 동시접속 사용자수에 따른 전송데이터량 

 Response Times vs Threads

 동시접속자수에 따른 응답시간의 변화 


아래는 추가로 JMeter Plugin 설치를 하여 사용할 수 있는 확장 기능을 정리했다.

 Response Times Disributions 

 x축 - 응답시간 인터벌,  y축 - 각 인터벌간 잡혀있는 샘플의 개수

 Active Threads Over Time Listener

 시간대별 살아있는 스레드의 개수

 Reponse Codes Per Second

 시간대별 Response Code 기록 (오류 발견시 아주 유용할듯 )

 Latencies Over Time

 Load Test시 Latency를 측정하는 그래프인데 별로 안좋은듯 피드백도 없고!

 Server Hits per Second

 Servers Hits 보여주는 그래프

 Bytes Throughput Over Time

 아주 중요한 그래프 (웹소켓 적용될지는 미지수)

 Composite Graph

 여러그래프를 함께 보여주도록 설정 가능



혹시 요청 url의 경우수가 많을 경우, WorkBench의 Http Proxy Server기능을 사용하여 요청 url을 레코딩할수가 있다. 


Thread Group에서의 설정값


아래는 Config Element에 잘 쓰는 놈중의 하나인 Counter 에 대한 설명이다.




아래는 ServerAgent 를 설치하여 cilent에서 서버의 cpu, memory usage 를 표로 보고 있는 그림




마지막으로 JMeter 사용시 주의사항이다.

Threads를 늘리거나 Listener를 많이 넣을 경우 메모리에 부하를 갈 수 있다. 모니터링 시간이 늘어나면 위험부담은 기하급수적으로 늘어나며 Heap 메모리 부족에러부터 다양한 리소스 부족 현상으로 빚어지는 에러로 에이징(장시간 부하)테스트등이 매끄럽게 진행이 되지 못한다.

그래서 해결방법은

리스너를 줄이거나 아니면 memory heap size를 많이 주는 것이다.

아래는 예제

Sometime I tune Jmeter options like:
JVM_ARGS="-Xms1024m -Xmx1024m -XX:+UseParallelGC -Xss1024k -XX:TenuredGenerationSizeIncrement=1m"


또하나는 Listener에 View Results Tree를 사용하지 말자!!! 기능테스트에서 사용하되, 부하테스트에서는 리소스가 없어 클라이언트가 먼저 리소스 다 잡아먹고 다운되버린다.

아래는 메뉴얼쪽 경고사항

18.3.6 View Results Tree

View Results Tree MUST NOT BE USED during load test as it consumes a lot of resources (memory and CPU). Use it only for either functional testing or during Test Plan debugging and Validation.



> Trouble Shoointg

테스트 중간에 Thread 개수가 많게 하여 테스트를 할 경우 Thread 개수가 증가하다가 나중에 그 개수가 점점 줄어들며 0으로 바뀌고 테스트가 종료가 되어야 

정확한 집계가 되는데 다음과 같이 Thread가 종료가 안되서 정확한 테스트 수치를 획득을 못할 경우가 있다. 

Q) i am running 100 threads concurrently for 5 mins using Jmeter 2.7 on website, once the execution duration is complete, it has to close all the running threads one by one and stop the execution completely, but Jmeter is left with few more threads(around 10-20 threads) without closing..

A)  

가능성 1 : those threads are still waiting on a response from the server

가능성 2 : This issue usually occurs when the requests to the application under test got high response times. The threads will be waiting for the pending response even after the specfied duration is elapsed. This can be avoided to an extent by allowing sufficient thread ramp down time or shut down time. Use Stepping thread group or ultimate thread group( these are JMeter plugins) to give an inclined ramp down instead of sudden shutdown as in normal thread group







Reference

1 : http://www.javaworld.com/javaworld/jw-07-2005/jw-0711-jmeter.html?page=1

2.  http://nico.vahlas.eu/2010/03/30/some-thoughts-on-stress-testing-web-applications-with-jmeter-part-2/

'IT > Tool' 카테고리의 다른 글

PowerShell 익숙해지기.  (0) 2015.03.03
Git  (0) 2013.04.01
캡쳐부터 자동 웹업로드되는 막강 툴! Cropper!  (0) 2013.03.25
JMeter - Java Request  (0) 2013.02.18
Posted by 억사마
IT/Tool2013. 2. 18. 14:35

Java Client 를 이용한 부하테스트를 위해서 JMeter 부하테스트 툴을 사용하기로 결정

  • 설치 프로그램

 프로그램

 설명

 Eclipse SDK

 소스 편집기 (텍스트 에디터도 무관) 

 Java Client 

 실제 부하 테스트 대상 클라이언트

 JMeter

 부하 테스트 툴 다운은 여기

 Maven

 실제 Exectuable Jar를 생성하기 위해Maven Assembly Plugin  사용

  • 셋팅
  1. JMeter 설치하고 나면 lib/ext 폴더에 D:\ide\apache-jmeter-2.9\lib\ext에 ApacheJMeter_core.jar, ApacheJMeter_java.jar 2개 파일들을 Client 단의 Class Path 설정 완료
  2. 실제로 테스트 코드가 들어갈 Class파일을 하나 만든다. 그 클래스는 org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient의 클래스를 상속받아야 한다. ( ApacheJMeter_core.jar, ApacheJMeter_java.jar 2개 사용됨)

  3. 상속을 아래하면 아래와 같이 소스를 개발하면 되는데 각 소스에 대한 설명이다. (출처)
    1) getDefaultParameters()

    This method is where you set parameters that you would like to get in JMeter Java Reqeust GUI. You do this by instantiating aorg.apache.jmeter.config.Arguments and calling its addArgument method for each parameter. For example:

    public Arguments getDefaultParameters() {
    Arguments args = new Arguments();
    args.addArgument("Service URL", "");
    args.addArgument("User Name", "");
    args.addArgument("Password", "");
    return args;
    }

    2) setupTest()

    Where you do any initialization (only once per thread) such as reading in the parameters, creating the Hessian proxy, etc. For example:

    public void setupTest(JavaSamplerContext context) {
    url = context.getParameter("Service URL");
    try {
    mySvc = (mySvcClassName)
    proxyFactory.create(mySvcClassName.class, url);
    } catch (Exception e) {
    e.printStackTrace();
    throw new RuntimeException("Error getting hessian proxy", e);
    }
    }

    3) runTest()

    JMeter will invoke it for each iteration of the test. This is where you would put code that invokes the service's methods and evaluate its result. The method returns a "org.apache.jmeter.samplers.SampleResult" object which is what you use to communicate the results to JMeter. For example:

    public SampleResult runTest(JavaSamplerContext context) {
    SampleResult result = new SampleResult();
    result.setSampleLabel("Call Hessian SVC");
    result.setDataType(SampleResult.TEXT);
    result.sampleStart();
    try {
    String custId = mySvc.authenticate(context.getParameter("User Name"), context.getParameter("Password"));
    if (custId == null) {
    result.setSuccessful(false);
    result.setResponseMessage("user authentication failed");
    result.setResponseData("Returned customer id is null".getBytes());
    }
    else {
    result.setSuccessful(true);
    result.setResponseCodeOK();
    result.setResponseMessage("Authentication successful");
    result.setResponseData(("customer id: " + custId).getBytes());
    }
    }
    catch (Throwable e) {
    StringWriter sw = new StringWriter();
    e.printStackTrace(new PrintWriter(sw));
    result.setSuccessful(false);
    result.setResponseMessage("Unexpected exception");
    result.setResponseData(sw.toString().getBytes());
    }

    result.sampleEnd();
    return result;
    }

    In the example above, the method setSuccessful indicates if the test passed or failed. The setting of the responseData is used for displaying whatever information you want in the response data tab of JMeter's "View Results Tree" listener.

    4) teardownTest()

    Where you do cleanup. Typically there is nothing you need to do here.

  4. 3번의 설명을 숙지하고 테스트 진행을 위한 테스트 코드를 삽입한다. 아래는 예제다.
    import org.apache.jmeter.config.Arguments;
    
    import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
    
    import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
    
    import org.apache.jmeter.samplers.SampleResult;
    
    import org.apache.jmeter.threads.JMeterContextService;
    
    import org.apache.jmeter.threads.JMeterVariables;
    
    
    
    
    
    public class JMeterTest extends AbstractJavaSamplerClient {
    
    
    
    
    
    	@Override
    
    	public SampleResult runTest(JavaSamplerContext arg0) {
    
    
    
    		JMeterVariables vars = JMeterContextService.getContext().getVariables();
    
    	    vars.put("demo", "demoVariableContent");
    
    	    
    
    	    System.out.println( " runTest() :: " +  arg0.getParameter("Service URL") );
    
    	    
    
    	    SampleResult sampleResult = new SampleResult();
    
    	    sampleResult.setSuccessful(true);
    
    	    sampleResult.setResponseCodeOK();
    
    	    sampleResult.setResponseMessageOK();
    
    	    return sampleResult;
    
    	}
    
    	
    
    	@Override
    
    	public Arguments getDefaultParameters() {
    
    
    
    		Arguments args = new Arguments();
    
    		
    
    		args.addArgument("Service URL", "127.0.0.1");
    
    		args.addArgument("Service IP", "8080");
    
    		args.addArgument("Service PORT", "8080");
    
    		args.addArgument("Call Count", "1000");
    
    		
    
    		//return super.getDefaultParameters();
    
    		return args;
    
    		
    
    	}
    
    	
    
    	@Override
    
    	public void setupTest(JavaSamplerContext context) {
    
    		// TODO Auto-generated method stub
    
    		//super.setupTest(context);
    
    		
    
    		String url = context.getParameter("Service URL");
    
    		System.out.println(url);
    
    		if(url.equals("127.0.0.1")) System.out.println("it's right!");
    
    		else System.out.println("It's wrong!");
    
    		
    
    	}
    
    	
    
    	@Override
    
    	public void teardownTest(JavaSamplerContext context) {
    
    		
    
    		System.out.println("It's all done~~ ");
    
    
    
    		super.teardownTest(context);
    
    	}
    
    	
    
    
    
    }
    

  5.  Exectuable Jar로 생성 (Maven Assembly Plugin 설명을 따라서 진행하면 간단히 생성 가능)
  6. 1)번 과정에서 생성된 jar를 jmeter의 lib하위 폴더에 넣고 bin\jmeter.bat를 실행시킨다.
  7. 아래 그림을 보면 Name하고 Comment는 원하는 테스트명을 넣고 ClassName이 중요하다 여기에서 내가 실행가능한 ClassName이 뜨면 된다.  

  8. 그러면 Thread Group 하위의 각종 보고 싶은 유형의 결과 리포트( Summary Report View Results in Tables등)의 유형을 선택하여 Run으로 돌리고 나서 결과 확인
  • 테스트 그럼 완ㄹ.


뱀다리) m2clipse와 cmd창에서 직접 실행시킨 maven하고 차이가 발생한다. 이유는 모르겠다. 

cmd창에서는 timeout이 계속 발생해서 dependency 라이브러리를 가져오지 못하고 

m2clipse는 문제가 없다. 이거 왜 이러지??!    다만.. 오류가 왕창 떨어질뿐..

아직도 메이븐 초보에서 벗어나긴 힘든가봐.










'IT > Tool' 카테고리의 다른 글

PowerShell 익숙해지기.  (0) 2015.03.03
Git  (0) 2013.04.01
캡쳐부터 자동 웹업로드되는 막강 툴! Cropper!  (0) 2013.03.25
JMeter  (0) 2013.02.26
Posted by 억사마