라봉이의 개발 블로그

[ngrinder] 2Core, 2GB Node.js 서버 간단한 GET 테스트(vuser: 99 test: 19,800, ) 본문

컴퓨터 사이언스/ngrinder 부하 테스트 정리

[ngrinder] 2Core, 2GB Node.js 서버 간단한 GET 테스트(vuser: 99 test: 19,800, )

Labhong 2019. 1. 1. 15:45
반응형
[ngrinder] 2Core, 2GB Node.js 서버 간단한 GET 테스트(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

 

결과


 

후기

  • 리눅스 TCP나 파일 디스크럽터를 커스텀하지 않은 채 서버를 구동한 것이기 때문에 TPS가 굉장히 낮았다.
  • 서버 성능이 아무리 낮아도 이 정도 성능 밖에 안나올 줄은 몰랐다.
  • 다음엔 node 클러스터링 후에 테스트 해보고 비교해 볼 예정이다.


반응형
Comments