라봉이의 개발 블로그

[ngrinder] 2Core, 2GB Node.js 서버 간단한 GET 테스트 (pm2 클러스터링 인스턴스 2개)(vuser- 99 test- 19,800) 본문

프레임워크, 툴/ngrinder

[ngrinder] 2Core, 2GB Node.js 서버 간단한 GET 테스트 (pm2 클러스터링 인스턴스 2개)(vuser- 99 test- 19,800)

Labhong 2019. 2. 3. 14:25
반응형
[ngrinder] 2Core, 2GB Node.js 서버 간단한 GET 테스트 (pm2 클러스터링 인스턴스 2개)(vuser- 99 test- 19,800)

사전 설정

  • Controller 스펙

    • 기종: 한성 Bossmonster lv. 67
    • OS: Windows10 pro 64bit
    • processor: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz, 2601Mhz, 4 코어, 8 논리 프로세서
    • RAM: 16.0 GB

     

  • Agent 스펙

    • 기종: MAC 애플 맥북프로 15형 레티나 리프레시 2015년형 (MJLQ2KH/A)
    • OS: MAC Mojave
    • processor: Intel Core i7 2.2 GHz
    • RAM: 16.0 GB

     

  • Target 스펙

    • OS: Ubuntu 14.04
    • processor: 2 Core
    • RAM: 2.0 GB
    • Process: 1개 (Not clustering)
  • 스크립트 ※ URI 설정만 한 기본 스크립트이다. 이전 포스트와 같다. 이전포스트

    import static net.grinder.script.Grinder.grinder
    
    import static org.junit.Assert.*
    
    import static org.hamcrest.Matchers.*
    
    import net.grinder.plugin.http.HTTPRequest
    
    import net.grinder.plugin.http.HTTPPluginControl
    
    import net.grinder.script.GTest
    
    import net.grinder.script.Grinder
    
    import net.grinder.scriptengine.groovy.junit.GrinderRunner
    
    import net.grinder.scriptengine.groovy.junit.annotation.BeforeProcess
    
    import net.grinder.scriptengine.groovy.junit.annotation.BeforeThread
    
    // import static net.grinder.util.GrinderUtils.* // You can use this if you're using nGrinder after 3.2.3
    
    import org.junit.Before
    
    import org.junit.BeforeClass
    
    import org.junit.Test
    
    import org.junit.runner.RunWith
    
    
    
    import java.util.Date
    
    import java.util.List
    
    import java.util.ArrayList
    
    
    
    import HTTPClient.Cookie
    
    import HTTPClient.CookieModule
    
    import HTTPClient.HTTPResponse
    
    import HTTPClient.NVPair
    
    
    
    /**
    
     * A simple example using the HTTP plugin that shows the retrieval of a
    
     * single page via HTTP. 
    
     * 
    
     * This script is automatically generated by ngrinder.
    
     * 
    
     * @author admin
    
     */
    
    @RunWith(GrinderRunner)
    
    class TestRunner {
    
    
    
    	public static GTest test
    
    	public static HTTPRequest request
    
    	public static NVPair[] headers = []
    
    	public static NVPair[] params = []
    
    	public static Cookie[] cookies = []
    
    
    
    	@BeforeProcess
    
    	public static void beforeProcess() {
    
    		HTTPPluginControl.getConnectionDefaults().timeout = 6000
    
    		test = new GTest(1, "1.201.xxx.xxx")
    
    		request = new HTTPRequest()
    
    		grinder.logger.info("before process.");
    
    	}
    
    
    
    	@BeforeThread 
    
    	public void beforeThread() {
    
    		test.record(this, "test")
    
    		grinder.statistics.delayReports=true;
    
    		grinder.logger.info("before thread.");
    
    	}
    
    	
    
    	@Before
    
    	public void before() {
    
    		request.setHeaders(headers)
    
    		cookies.each { CookieModule.addCookie(it, HTTPPluginControl.getThreadHTTPClientContext()) }
    
    		grinder.logger.info("before thread. init headers and cookies");
    
    	}
    
    
    
    	@Test
    
    	public void test(){
    
    		HTTPResponse result = request.GET("http://1.201.xxx.xxx:xxxx/", params)
    
    
    
    		if (result.statusCode == 301 || result.statusCode == 302) {
    
    			grinder.logger.warn("Warning. The response may not be correct. The response code was {}.", result.statusCode); 
    
    		} else {
    
    			assertThat(result.statusCode, is(200));
    
    		}
    
    	}
    
    }
    
    
    
    
  • 테스트 설정 (이전 포스트와 같다.) 이전 포스트

    • 에이전트: 1
    • vuser: 99 (프로세스: 3, 스레드: 33)
    • 실행횟수: 200

 

결과


 

후기

  • 에러가 확실히 줄었다. 194개였던 에러가 2개로 확 줄었다.

  • TPS가 살짝 줄었다. 인스턴스가 늘었는데 TPS가 줄은 것은 어떤 이유일까??

    • 가설1. pm2가 요청에 대해 로드밸런싱을 처리하기 때문에 줄은 것 같다.
    • 가설2. 네트워크 대역폭에 문제가 있다.
    • 가설3. 네트워크 I/O 자원에 대해 프로세스 간 경합이 있었다.
  • TPS가 줄었기 때문에 동작 시간(Run time)은 1분 정도 늘었다.

  • 다음 테스트땐 네트워크 대역폭 모니터링 툴 bmon을 이용하여 네트워크를 체크해봐야할 듯 하다.

 

반응형
Comments