ãã®è¨äºã¯ MIXI DEVELOPERS Advent Calendar 2022 6 æ¥ç®ã®è¨äºã§ãã
è² è·è©¦é¨ãè¡ãæ©ä¼ãå¹´ã«ä½åº¦ãããã®ã§ããã以åã¾ã§ã¯vegetaã使ã£ã¦ãã¾ãããã¡ãã£ã¨é«ãã®è² è·ããããæã®æåããããããªããk6ã試ãã¦ã¿ãã¨ããä¸æºãç¡ãã£ãã®ã§æè¿ã¯k6ã常ç¨ãã¦ãã¾ãã
ãããªk6ãããã¡ãã£ã¨ä½¿ãããªãããã«è²ã ã¨ã¾ã¨ãã¦ã¿ãããã¨æãã¾ãã
k6ã¨ã¯ï¼
Grafana Labsãéçºããè² è·ãã¼ã«ã
ãã¼ã«èªä½ã¯Go製ã§ãè² è·ã·ããªãªãJavaScriptã§æ¸ãã¾ãã
è² è·ã·ããªãªã¯k6 Browser Recorderã¨ããChromeæ¡å¼µã使ãã°ãã©ã¦ã¸ã³ã°ãã¦ããã ãã§ä½æå¯è½ã§ãk6 Cloudã使ã£ãWebä¸ã§ã®ã·ããªãªä½æã»ç®¡çã»å®è¡ãå¯è½ã§ãã
ããããGitHubä¸ã§ã·ããªãªã管çããªãã¦ãããã¨ããã®ã¯å人çã«ä¾¿å©ã ãªã¨æã£ãç¹ã§ã¯ããã¾ãð
ï¼ã©ãã®ãªãã¸ããªã«ç½®ãã®ï¼åé¡ã¨ãèããªãã¦æ¸ãï¼
ãã以å¤ã«ãHTTPãWebSocketãgRPCãªã©ã®ãã«ããããã³ã«ãµãã¼ãããã«ã¹ã¿ã ãã«ãã使ããã¨ã«ããä¾ãã°IAPã®çªç ´ãk6èªä½ã«çµã¿è¾¼ãã ããªã©ã®æ¡å¼µæ§ãæããããã¨ãåºæ¥ã¾ããï¼è©³ããã¯xk6ãåç §ï¼
ãã®ä»ãå å®ããããã¥ã¡ã³ãããã¡ã«æ´æ°ããã¦ããããã°ãªã©ã¦ã¼ã¶ã¼ã«å¯¾ãã¦ã®ãµãã¼ããæããããªãã§ãã
åºæ¬çãªä½¿ãæ¹
ã¾ãã¯ã¤ã³ã¹ãã¼ã«ãããMacã®å ´å㯠brew install k6
ã§okããã以å¤ã¯ãã¡ããåç
§ã
ã¤ã³ã¹ãã¼ã«ãçµããã¾ãããã次ã«ã·ããªãªã®ä½æã§ããããã¥ã¡ã³ãã«ãããæå°ã®å½¢ã§ã¾ãã¯è©¦ãã¦ã¿ã¾ãããã
ã·ããªãªãæ ¼ç´ãããã£ã¬ã¯ããªã¨ã㦠k6
ã¨ããå称ã§ãã£ã¬ã¯ããªãä½æãããã®ç´ä¸ã«ä»¥ä¸ã®å
容㮠test.js
ãä½æãã¦ãã ããã
k6å´ã§ãã¹ãç¨ã«ç¨æããã¦ãã https://test.k6.io
ã«å¯¾ãã¦Getãªã¯ã¨ã¹ããæãããã®ï¼ç§å¾ã«ãã¹ããçµäºããã·ããªãªã«ãªãã¾ããã§ã¯ããã®ããã«ãªã£ã¦ããã®ãå®è¡ãã¦ã¿ã¾ãããã
$ cd k6 $ k6 run test.js /\ |â¾â¾| /â¾â¾/ /â¾â¾/ /\ / \ | |/ / / / / \/ \ | ( / â¾â¾\ / \ | |\ \ | (â¾) | / __________ \ |__| \__\ \_____/ .io execution: local script: test.js output: - scenarios: (100.00%) 1 scenario, 1 max VUs, 10m30s max duration (incl. graceful stop): * default: 1 iterations for each of 1 VUs (maxDuration: 10m0s, gracefulStop: 30s) running (00m01.7s), 0/1 VUs, 1 complete and 0 interrupted iterations default â [======================================] 1 VUs 00m01.7s/10m0s 1/1 iters, 1 per VU data_received..................: 17 kB 10 kB/s data_sent......................: 442 B 260 B/s http_req_blocked...............: avg=518.34ms min=518.34ms med=518.34ms max=518.34ms p(90)=518.34ms p(95)=518.34ms http_req_connecting............: avg=175.25ms min=175.25ms med=175.25ms max=175.25ms p(90)=175.25ms p(95)=175.25ms http_req_duration..............: avg=179.72ms min=179.72ms med=179.72ms max=179.72ms p(90)=179.72ms p(95)=179.72ms { expected_response:true }...: avg=179.72ms min=179.72ms med=179.72ms max=179.72ms p(90)=179.72ms p(95)=179.72ms http_req_failed................: 0.00% â 0 â 1 http_req_receiving.............: avg=465µs min=465µs med=465µs max=465µs p(90)=465µs p(95)=465µs http_req_sending...............: avg=50µs min=50µs med=50µs max=50µs p(90)=50µs p(95)=50µs http_req_tls_handshaking.......: avg=330.41ms min=330.41ms med=330.41ms max=330.41ms p(90)=330.41ms p(95)=330.41ms http_req_waiting...............: avg=179.21ms min=179.21ms med=179.21ms max=179.21ms p(90)=179.21ms p(95)=179.21ms http_reqs......................: 1 0.587392/s iteration_duration.............: avg=1.7s min=1.7s med=1.7s max=1.7s p(90)=1.7s p(95)=1.7s iterations.....................: 1 0.587392/s vus............................: 1 min=1 max=1 vus_max........................: 1 min=1 max=1
äºæ³éãã«Getãªã¯ã¨ã¹ããï¼åº¦æãã¦ã¾ããï¼ãã®ããã«CLIã§ã¹ã¯ãªãããå®è¡ããã¨çµ±è¨ãã¼ã¿ã表示ããã¾ãã
ã§ã¯è¡¨ç¤ºãããé
ç®ã«ã¤ãã¦ä¸ã¤ãã¤è¦ã¦ããã¾ãããã
running (00m01.7s), 0/1 VUs, 1 complete and 0 interrupted iterations default â [======================================] 1 VUs 00m01.7s/10m0s 1/1 iters, 1 per VU
ãã¹ãå®è¡æã®ããã°ã¬ã¹ãã¼ã§ãããããã«ã¯VUSï¼virtual usersï¼ä»®æ³ã¦ã¼ã¶ã¼ï¼ã®æ°ã¨å®è¡æéãã¤ãã¬ã¼ãæ°ã¨ä»®æ³ã¦ã¼ã¶ã¼ã®å®è¡æ°ã«ãªãã¾ãã
- data_receivedï¼ç·ãã¼ã¿åä¿¡æ°
- data_sentï¼ç·ãã¼ã¿éä¿¡æ°
- http_req_blockedï¼TCPæ¥ç¶ãããããã³ã°ãããæé
- http_req_connectingï¼TCPæ¥ç¶ã®ç¢ºç«ã«ããã£ãæé
- http_req_durationï¼ãªã¯ã¨ã¹ããéä¿¡ãã¦ã¬ã¹ãã³ã¹ãåãåãã¾ã§ã®æéï¼http_req_sending + http_req_waiting + http_req_receivingï¼
- expected_responseï¼http_req_durationã®ä¸ã§ãHTTPã¹ãã¼ã¿ã¹ã³ã¼ãã200~399ã®ãªã¯ã¨ã¹ãã®ã¿ã®å¤
- http_req_failedï¼ãªã¯ã¨ã¹ãã失æããæ°
- http_req_receivingï¼ã¬ã¹ãã³ã¹ãåä¿¡ãã¦ããæé
- http_req_sendingï¼ãªã¯ã¨ã¹ããéä¿¡ãã¦ããæé
- http_req_tls_handshakingï¼TLSãã³ãã·ã§ã¤ã¯ã«ããã£ãæé
- http_req_waitingï¼ã¬ã¹ãã³ã¹ãå¾ ã£ã¦ããæéï¼TTFBã®ãã¨ï¼
- http_reqsï¼éä¿¡ããããªã¯ã¨ã¹ãæ°
- iteration_durationï¼ã·ããªãªã§è¨å®ãããï¼ã¤ãã¬ã¼ã·ã§ã³ã«ããã£ãå ¨ã¦ã®æé
- iterationsï¼ï¼VUãå®è¡ããã¤ãã¬ã¼ã·ã§ã³ã®æ°
- vusï¼çµäºæç¹ã§ã®VUæ°
- vus_maxï¼å®è¡ä¸ã§ã®æ大VUæ°
è²ã
ããã¾ãããå人çã«è¦ã¦ããææ¨ã¯ http_req_failed
㨠http_req_duration
ãããã§ããããå¿è«ãä»ã®ææ¨ãä½ãããã®ç°å¸¸ãªå¤ãåºã¦ããã°è¦ã¾ãããåºæ¬ã¯ãã®ï¼ã¤ãè¦ã¦ããã°ããããªã¨æãã¾ãã
ã·ããªãªãCLIã§å®è¡ããå ´åã¯ãã®ãããªåºåã§ãããk6 Cloudã§ã¯ãã®ææ¨ãã°ã©ãã§å¯è¦åãããå³ã確èªãããã¨ãã§ãã¾ãã
â»ãã ãã詳細ã«åºåãããã®ã¯CLIã®æ¹ãªã®ã§ç¹å¥ãªãã ãããç¡ããã°CLIã§å®è¡ããã®ããªã¹ã¹ã¡ãã¾ãï¼é«è² è·ã®å ´åã¯k6 Cloudã®æ¹ãããããï¼
ã¾ãããã®ææ¨ã¯éçºè ãã«ã¹ã¿ã ãããã¨ãåºæ¥ãããã¯å¾ã»ã©èª¬æè´ãã¾ãã
ããã¾ã§ãæå°ã®å½¢ã§ã®ã·ããªãªä½æâå®è¡ã¾ã§ã®ããã¼ã«ãªãã¾ãã
k6 run
ããã»ã©å®è¡ã®éã«å©ç¨ãã k6 run
ã«ã¤ãã¦ããå°ã詳ããè¦ã¦ããã¾ãã
k6 run
ã¯ãªãã·ã§ã³ã§ã·ããªãªã®å®è¡ã®ä»æ¹ãå¤ãããã¨ãã§ãã¾ããä¾ãã°ãããã»ã©ã¯ã·ããªãªãä¸åçµããã°å®è¡ãçµäºãã¦ãã¾ããããã30sã®éã50rpsã§è² è·ãããããããªã©ã¨ãã£ãè¦æã¯åºã¦ããã¨æãã¾ãããããã£ãæã«ãªãã·ã§ã³ãä»ãã¦ã¿ã¾ãããã
ä»åã¯ãã¹ãã®ããã«ããå°ã軽ãè² è·ã«ãã¦ã¿ã¾ãã
$ k6 run test.js -d 5s --rps 20 /\ |â¾â¾| /â¾â¾/ /â¾â¾/ /\ / \ | |/ / / / / \/ \ | ( / â¾â¾\ / \ | |\ \ | (â¾) | / __________ \ |__| \__\ \_____/ .io execution: local script: test.js output: - scenarios: (100.00%) 1 scenario, 1 max VUs, 35s max duration (incl. graceful stop): * default: 1 looping VUs for 5s (gracefulStop: 30s) running (05.2s), 0/1 VUs, 4 complete and 0 interrupted iterations default â [======================================] 1 VUs 5s data_received..................: 52 kB 9.9 kB/s data_sent......................: 736 B 141 B/s http_req_blocked...............: avg=120.06ms min=6µs med=11.5µs max=480.22ms p(90)=336.16ms p(95)=408.19ms http_req_connecting............: avg=44.02ms min=0s med=0s max=176.08ms p(90)=123.26ms p(95)=149.67ms http_req_duration..............: avg=182.34ms min=179.94ms med=182.49ms max=184.42ms p(90)=184.05ms p(95)=184.24ms { expected_response:true }...: avg=182.34ms min=179.94ms med=182.49ms max=184.42ms p(90)=184.05ms p(95)=184.24ms http_req_failed................: 0.00% â 0 â 4 http_req_receiving.............: avg=143.75µs min=86µs med=137.49µs max=214µs p(90)=201.7µs p(95)=207.84µs http_req_sending...............: avg=36.25µs min=26µs med=30µs max=59µs p(90)=50.6µs p(95)=54.8µs http_req_tls_handshaking.......: avg=75.71ms min=0s med=0s max=302.86ms p(90)=212ms p(95)=257.43ms http_req_waiting...............: avg=182.16ms min=179.81ms med=182.26ms max=184.31ms p(90)=183.9ms p(95)=184.11ms http_reqs......................: 4 0.766934/s iteration_duration.............: avg=1.3s min=1.18s med=1.18s max=1.66s p(90)=1.51s p(95)=1.59s iterations.....................: 4 0.766934/s vus............................: 1 min=1 max=1 vus_max........................: 1 min=1 max=1
å®è¡ãã¦ã¿ã¾ãããã20rpsãæå®ããã®ã«0.7rpsããåºã¦ãã¾ããããvusã«æ³¨ç®ãã¦ããã ãã¨vusã1ããçæããã¦ããªãã®ã§ã20rpsãå®è¡ããããã«vusãå¢ããã¦ã¿ã¾ãããã
$ k6 run test.js -d 5s --rps 20 -u 40 /\ |â¾â¾| /â¾â¾/ /â¾â¾/ /\ / \ | |/ / / / / \/ \ | ( / â¾â¾\ / \ | |\ \ | (â¾) | / __________ \ |__| \__\ \_____/ .io execution: local script: test.js output: - scenarios: (100.00%) 1 scenario, 60 max VUs, 35s max duration (incl. graceful stop): * default: 60 looping VUs for 5s (gracefulStop: 30s) running (08.0s), 00/60 VUs, 135 complete and 0 interrupted iterations default â [======================================] 60 VUs 5s data_received..................: 1.9 MB 237 kB/s data_sent......................: 34 kB 4.3 kB/s http_req_blocked...............: avg=158.32ms min=3µs med=13µs max=465.14ms p(90)=358.31ms p(95)=364.97ms http_req_connecting............: avg=77.78ms min=0s med=0s max=183.75ms p(90)=177.89ms p(95)=180.75ms http_req_duration..............: avg=193.77ms min=171.88ms med=179.31ms max=362.84ms p(90)=188.16ms p(95)=346.3ms { expected_response:true }...: avg=193.77ms min=171.88ms med=179.31ms max=362.84ms p(90)=188.16ms p(95)=346.3ms http_req_failed................: 0.00% â 0 â 135 http_req_receiving.............: avg=15.43ms min=40µs med=122µs max=178.5ms p(90)=418.8µs p(95)=170.85ms http_req_sending...............: avg=47.08µs min=12µs med=44µs max=122µs p(90)=83.2µs p(95)=95.3µs http_req_tls_handshaking.......: avg=80.48ms min=0s med=0s max=280.26ms p(90)=180.7ms p(95)=184.18ms http_req_waiting...............: avg=178.29ms min=171.72ms med=178.65ms max=188.4ms p(90)=184.01ms p(95)=185.03ms http_reqs......................: 135 16.97481/s iteration_duration.............: avg=2.85s min=1.63s med=2.65s max=4.5s p(90)=3.81s p(95)=4.15s iterations.....................: 135 16.97481/s vus............................: 18 min=18 max=60 vus_max........................: 60 min=60 max=60
vusã40ã«ãã¦ã¿ãã¨ããã20rpsã«è¿ä»ãã¾ãããï¼ãã®ããã«å®è¡ããç°å¢ããªãã·ã§ã³ã«ãã£ã¦èª¿æ´ãããã¨ãåºæ¥ã¾ããæ§ã
ãªãªãã·ã§ã³ãç¨æããã¦ããã®ã§æ¯éã¨ã k6 run --help
ã§ãªãã·ã§ã³ä¸è¦§ãçºãã¦é ãããã®ã§ããããã®ä¸ãã使ãæã®å¤ããªãã·ã§ã³ãæç²ãã¾ãã
// --user-agentï¼ã¦ã¼ã¶ã¼ã¨ã¼ã¸ã§ã³ãã®æå® $ k6 run test.js --user-agent "test-agent" // --outï¼ææ¨ã®è©³ç´°ãã¼ã¿ãåºåããªã¯ã¨ã¹ãæ¯ã«HTTPã¹ãã¼ã¿ã¹ã³ã¼ãããªã¯ã¨ã¹ã/ã¬ã¹ãã³ã¹ã®æ¥æãªã©ã®æ å ±ã確èªã§ãã $ k6 run test.js --out json=result.json // --log-outputï¼ç»é¢ä¸ã§ã®ãã°ã®è¡¨ç¤ºè¨å®ããªã¯ã¨ã¹ãã®ã¿ã¤ã ã¢ã¦ããªã©é »çºããåºåãæå¶ããã®ã«ä½¿ã $ k6 --log-output none run test.js
k6 Browser Recorderãå©ç¨ããã·ããªãªã®ä½æ
k6ã¨ã¯ï¼ã§ç´¹ä»ããk6ã®Chromeæ¡å¼µã»ãk6 Browser Recorder使ã£ã¦ã·ããªãªãä½æãã¦ã¿ã¾ããããä»åã¯example.comã使ã£ã¦ã·ããªãªãä½æãã¦ã¿ã¾ãã
äºåä½æ¥ã¨ã㦠k6 Browser Recorderãã¤ã³ã¹ãã¼ã«ããhttps://app.k6.io/account/login ã«ã¢ã¯ã»ã¹ãããã°ã¤ã³ã¾ãã¯æ°è¦ç»é²ãæ¸ã¾ãã¦ããã¦ãã ããã
ã¾ãã¯ãexample.comã«é£ã³ã¾ãããã
k6 Browser Recorderãå®è¡ãã¦ã¿ã¾ãã
Start recordingãæ¼ä¸ãã¾ãã
ãã¼ã«ã¦ã£ã³ãã¦ãèªã¿è¾¼ã¿ç¶æ ã«ãªããæ«ãããã¨ä¸è¨ã®ç»é¢ã«ãªãã¾ãã®ã§ããããã¾ããããã¼ã¸ãä¸åº¦ãªãã¼ããã¦ã¿ã¦ãã ããã ãã®å¾ãå®å ¨ã«ãã¼ã¸ã®èªã¿è¾¼ã¿ãå®äºãããStopãæ¼ä¸ãã¾ãã
ããã¨ãæ°è¦ã¿ããéãk6 Cloudã表示ããã¾ãã
Test builderã¨Script editorãæåã«ããã®ã§ãããå人çã«ã¯Script editorãé¸æããã®ããªã¹ã¹ã¡ãã¦ãã¾ããå¾ããå¤ããããã®ã§ã©ã¡ãã§ãããã®ã§ãããéçºè
ãæ±ãã«ã¯Script editorã®æ¹ã馴æã¿ããJSã®æ¸ãããã¨ãã£ã¿ã¼ãéãããã®ã§ãã¡ããé¸ã¶ã®ãè¯ããã¨ã
Generate sleepã¯500ms以ä¸ããã£ã¦ããå¦çéã«èªåã§sleepãå
¥ãã¦ãããã®ã§ãããèªåã¯å¿
è¦ãªãã¨æãã¦ããã®ã§ãã¤ãé¸æãã¦ãã¾ããã
ã¾ããä»åã¯è¡¨ç¤ºãããã¦ãã¾ãããcssãjsãªã©ã®static assetsãåå¨ããå ´åã¯ããã®ã¢ã¯ã»ã¹å¦çãã¹ã¯ãªããã«å«ãããã©ãããå¤é¨ãã¡ã¤ã³ã¸ã®ãªã¯ã¨ã¹ããå«ãããã©ãããé¸æã§ãã¾ããå¤é¨ãã¡ã¤ã³ã¸ã®ãªã¯ã¨ã¹ãã¯èªåã§ç®¡çãã¦ãããã®ä»¥å¤ã¯é¤ãã®ãè¯ãããã§ãstatic assetsã«é¢ãã¦ã¯åºæ¬ã¯å«ãã§ããã¦ç¶æ³ã«ãã£ã¦ã¯é¤ãããããã®ãè¯ãããªã¨æãã¾ãã
é¸æãçµããã¾ãããSaveã§Script editorã«ç§»åãã¾ãã
ããããRun Testãæ¼ä¸ãããã¨ã§ãã®ã¾ã¾å®è¡ã§ãã¾ãããä¸åº¦çæãããã¹ã¯ãªãããæå ã§jsãã¡ã¤ã«ã«ãã¦CLIã§å®è¡ãããè¯ããç¶æ³ã«ãã£ã¦ä½¿ãåãã¦ã¿ã¦ãã ããã
ã·ããªãªã®ä½æä¾
ããããã¯ããå°ãã·ããªãªã®ä½æãå ·ä½çã«ãã£ã¦ããã¾ããããã»ã©ä½æããexapmle.comã¸ã®ãªã¯ã¨ã¹ããåå°ã«æ¹é ãã¦ããã¾ãã
çæããããã®ã³ã¼ããè¦ãã¨ãã«æ³¨ç®ãã¹ã㯠export const options
ã§ãã k6 run
ã®ãªãã·ã§ã³ãç´¹ä»ãã¾ããããããã«ç´°ãã調æ´çãå¯è½ã«ããã®ããã®optionsã§ãã
ç¾å¨ã¯ãvusã10ã§5åéè² è·ãããããã¨ããæ¡ä»¶ã§ã·ããªãªãæ¸ããã¦ãã¾ããããããã40vusï¼å¿
è¦ãããã°å¢ããï¼ã§20rpsã®è² è·ã5ç§éããããã¨ãã¦ã¿ã¾ãããã
確èªã®ããããã¡ããå®è¡ãã¦ã¿ãã¨
$ k6 run test.js /\ |â¾â¾| /â¾â¾/ /â¾â¾/ /\ / \ | |/ / / / / \/ \ | ( / â¾â¾\ / \ | |\ \ | (â¾) | / __________ \ |__| \__\ \_____/ .io execution: local script: test.js output: - scenarios: (100.00%) 1 scenario, 100 max VUs, 35s max duration (incl. graceful stop): * test_scenario: 20.00 iterations/s for 5s (maxVUs: 40-100, gracefulStop: 30s) running (06.1s), 000/040 VUs, 101 complete and 0 interrupted iterations test_scenario â [======================================] 000/040 VUs 5s 20 iters/s â page_1 - http://example.com/ data_received..................: 162 kB 26 kB/s data_sent......................: 11 kB 1.8 kB/s group_duration.................: avg=159.18ms min=108.62ms med=117.98ms max=247.32ms p(90)=231.3ms p(95)=238.23ms http_req_blocked...............: avg=44.95ms min=4µs med=15µs max=121.48ms p(90)=114.97ms p(95)=117.98ms http_req_connecting............: avg=44.88ms min=0s med=0s max=121.35ms p(90)=114.84ms p(95)=117.84ms http_req_duration..............: avg=113.97ms min=108.32ms med=114.34ms max=129.69ms p(90)=120.07ms p(95)=120.83ms { expected_response:true }...: avg=113.97ms min=108.32ms med=114.34ms max=129.69ms p(90)=120.07ms p(95)=120.83ms http_req_failed................: 0.00% â 0 â 101 http_req_receiving.............: avg=124.53µs min=44µs med=125µs max=254µs p(90)=182µs p(95)=186µs http_req_sending...............: avg=75.37µs min=24µs med=57µs max=426µs p(90)=138µs p(95)=168µs http_req_tls_handshaking.......: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s http_req_waiting...............: avg=113.77ms min=108.13ms med=114.13ms max=129.51ms p(90)=119.93ms p(95)=120.63ms http_reqs......................: 101 16.524309/s iteration_duration.............: avg=1.16s min=1.1s med=1.11s max=1.24s p(90)=1.23s p(95)=1.23s iterations.....................: 101 16.524309/s vus............................: 40 min=40 max=40 vus_max........................: 40 min=40 max=40
16.5rpsã¨ãããã¨ã§20rpsã«è¿ãå¤ãåºãã¦ãã¾ããï¼ããã§ã¯åå°ããã®å¤æ´ç¹ãè¦ã¦ã¿ã¾ãã
export const options = { scenarios: { test_scenario: {
ãã¦ãoptionsã®ä¸ã§ scenarios
ã¨ããã®ãè¨å®ããã¦ãã¾ããããã¯VUSãã¤ãã¬ã¼ã·ã§ã³ã®å
·ä½çãªè¨å®ãè¡ãéã«ä½¿ããããã®ã§ã詳ããã¯ãã¡ãã«æ¸ãã¦ããã¾ãããã¨ã°ã¼ãã¥ã¼ã¿ã¼ã¨å¼ã°ããå®è¡ã¨ã³ã¸ã³ã®æå®ããå®è¡ãã¿ã¼ã³ã®è©³ç´°ãªè¨å®ã§ããç¾å®çãªè² è·è¨æ¸¬ãå¯è½ã«ãªãã¾ãã
optionsã« rps
ã¨ããè¨å®é
ç®ãããã®ã§ãããéæ¨å¥¨ã¨ãªã£ã¦ãããã constant-arrival-rate
ã¨ã°ã¼ãã¥ã¼ã¿ã¼ã使ã£ãä¸å®ã®ãªã¯ã¨ã¹ãéåºãè¡ãæ¹æ³ãåã£ã¦ãã¾ãã
test_scenario
ã¯ä»»æã®ãã¼ã¨ãªã£ã¦ãã¾ãã®ã§ãé©å½ãªã·ããªãªã«åºã¥ãååãä»ãã¦ãã ããã
// rate, timeUnitãå®è¡ããããã®Executor executor: 'constant-arrival-rate', duration: '5s', // timeUnitã§æå®ãããæéæ¯ã«å復ãããã¹ãåæ° rate: 20, // rateãå復ãããæé timeUnit: '1s', // åæã«å²ãå½ã¦ãããVUSæ° preAllocatedVUs: 40, // VUSã足ããªãã£ãå ´åã«å¢ããæ大VUSæ° maxVUs: 100,
scenarios
ã§è¨å®ããã¦ããå
容ã§ãããã³ã¡ã³ãã«æ¸ãã¦ããéãã®è¨å®ããã¦ããæãã§ããè¨å®å¤ã¯optionsã§ãè¨å®ã§ããå¤ã¯è¨å®ã§ããã¨ã°ã¼ãã¥ã¼ã¿ã¼æ¯ã«è¨å®ã§ãããã®ãéã£ããããã®ã§ãã¾ãã¯ã¨ã°ã¼ãã¥ã¼ã¿ã¼ã®ææ¡ãããããåã¨ã°ã¼ãã¥ã¼ã¿ã¼ã®è¨å®å¤ã確èªãã¦ããã®ãããã§ãããã
ãã¨ãç§ãå¿
ãä»ãã¦ãããªãã·ã§ã³ãããã¾ã㦠discardResponseBodies: true
ãä»ãã¦ããã®ããªã¹ã¹ã¡ãã¾ãããã¡ãã¯ã¬ã¹ãã³ã¹ããã£ãç ´æ£ãããã©ããã®è¨å®ã§ãããã©ã«ãã§ã¯ç ´æ£ããªãè¨å®ã«ãªã£ã¦ããã®ã§ããå¿
è¦ããªããã¨ãã»ã¨ãã©ã ã¨æãã¾ãã®ã§ããã¹ãè² è·ãæ¸ããããã«ç ´æ£ãããè¨å®ã«ãã¦ããã¾ãããã
ããä¸ã¤ããã¡ãã¯ãªãã·ã§ã³ã§ã¯ãªãã®ã§ãã http.setResponseCallback(http.expectedStatuses({ min: 200, max: 399 }));
ã¨ãããä½ã®HTTPã¹ãã¼ã¿ã¹ã³ã¼ããæåã¨ã¿ãªãã®ãï¼ããè¨å®ãããã¨ãã§ãã¾ããããã©ã«ãã§200~399ã¾ã§ã¯æåæ±ããªã®ã§ãããå ´åã«ãã£ã¦ã¯ç¹å®ã®HTTPã¹ãã¼ã¿ã¹ã³ã¼ã以å¤ã¯æåã¨ããããªãã¨ããæã«ä½¿ãã¾ãã
試ãã«201~399ã¾ã§ã¯æåã¨ããå ´åã«ã©ããªãããã£ã¦ã¿ã¾ãããã
/\ |â¾â¾| /â¾â¾/ /â¾â¾/ /\ / \ | |/ / / / / \/ \ | ( / â¾â¾\ / \ | |\ \ | (â¾) | / __________ \ |__| \__\ \_____/ .io execution: local script: test.js output: - scenarios: (100.00%) 1 scenario, 100 max VUs, 35s max duration (incl. graceful stop): * test_scenario: 20.00 iterations/s for 5s (maxVUs: 40-100, gracefulStop: 30s) running (06.1s), 000/040 VUs, 101 complete and 0 interrupted iterations test_scenario â [======================================] 000/040 VUs 5s 20 iters/s â page_1 - http://example.com/ data_received..............: 162 kB 26 kB/s data_sent..................: 11 kB 1.8 kB/s group_duration.............: avg=160.16ms min=107.11ms med=118.32ms max=253.38ms p(90)=235.91ms p(95)=239.88ms http_req_blocked...........: avg=45.4ms min=3µs med=15µs max=132.49ms p(90)=117.31ms p(95)=118.75ms http_req_connecting........: avg=45.25ms min=0s med=0s max=121.77ms p(90)=117.18ms p(95)=118.65ms http_req_duration..........: avg=114.49ms min=106.91ms med=115.03ms max=123.16ms p(90)=119.73ms p(95)=120.56ms http_req_failed............: 100.00% â 101 â 0 http_req_receiving.........: avg=117.94µs min=19µs med=93µs max=2.62ms p(90)=135µs p(95)=152µs http_req_sending...........: avg=73.29µs min=17µs med=56µs max=281µs p(90)=147µs p(95)=167µs http_req_tls_handshaking...: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s http_req_waiting...........: avg=114.3ms min=106.79ms med=114.85ms max=122.99ms p(90)=119.6ms p(95)=120.32ms http_reqs..................: 101 16.504622/s iteration_duration.........: avg=1.16s min=1.1s med=1.11s max=1.25s p(90)=1.23s p(95)=1.24s iterations.................: 101 16.504622/s vus........................: 40 min=40 max=40 vus_max....................: 40 min=40 max=40
æ³å®éãã http_req_failed
ã100%ã§å
¨ã¦å¤±æã¨ãªã£ã¦ãã¾ããã
ã«ã¹ã¿ã ã¡ããªã¯ã¹ã®ä½æ
è² è·ã®å®è¡å¾ã«è¡¨ç¤ºãããææ¨ãã«ã¹ã¿ãã¤ãºãã¦ã¿ã¾ããããè¨å®ã§ããã«ã¹ã¿ã ã¡ããªã¯ã¹ã«ã¯ä»¥ä¸ã®ï¼ç¨®é¡ãããã¾ãã
- Counterï¼ç´¯ç©å¤ãå¤å®ããææ¨ãä¾ãã°ãHTTPã¹ãã¼ã¿ã¹ã³ã¼ãä¸ã¯æåãã¦ããããã¨ã©ã¼ã³ã¼ããã¬ã¹ãã³ã¹ã§è¿ãã¦ããå ´åã«ãããã£ãã¬ã¹ãã³ã¹ã1件ã§ãããã°å¤±æã¨ãããã¿ãããªãã¨ãåºæ¥ãã
- Gaugeï¼ææ°ã®å¤ã常ã«å¤å®ããææ¨ãä¾ãã°ãã¬ã¹ãã³ã¹ããã£ã®ãµã¤ãºããã以ä¸ã ã£ãã失æãã®ãããªãã¨ãåºæ¥ãã
- Rateï¼è¿½å ããå¤ã®å²åãå¤å®ããææ¨ãä¾ãã°ãã¨ã©ã¼çã10%以ä¸ãªã失æã®ãããªãã¨ãåºæ¥ãã
- Trendï¼è¿½å ããå¤ã®çµ±è¨ï¼æå°ãæ大ãå¹³åããã¼ã»ã³ã¿ã¤ã«ï¼ãå¤å®ããææ¨ãä¾ãã°ãå¹³åã¬ã¹ãã³ã¹ã¿ã¤ã ãããms以ä¸ãªã失æã®ãããªãã¨ãåºæ¥ãã
ããããã®ã«ã¹ã¿ã ã¡ããªã¯ã¹ã«å¯¾ãã¦ã thresholds
ã¨ããæ¡ä»¶ãè¨è¿°ãããã¨ã§æ©è½ããã®ã§ããããã㧠abortOnFail
ãè¨å®ããã°å¤±æããæç¹ã§è² è·è¨æ¸¬ãä¸æãããã¨ãåºæ¥ããã delayAbortEval
ã§å¤±æå¾ãæå®æéè¨æ¸¬ã¯ç¶ããã¨ãã£ããã¨ãå¯è½ã§ãã
ãã®ï¼ã¤ã®ã«ã¹ã¿ã ã¡ããªã¯ã¹ãå ããã·ããªãªãæ¸ãã¦ã¿ã¾ããã®ã§ãåèã«ãã¦ã¿ã¦ãã ããã
ã¾ã ã¾ã 奥ãæ·±ãk6
ä»åç´¹ä»ããã®ã¯k6ã®è¦ç´ ã®ã¾ã ã¾ã ä¸é¨ã§ããä»ã«ã setup
teardown
ãã check
ã使ã£ãã·ããªãªã®æ¸ãæ¹ãªã©ãããã¾ãã®ã§ãããã¥ã¡ã³ããèªãã§ç¿çãã¦ã¿ã¦ãã ããï¼