brunch

You can make anything
by writing

C.S.Lewis

by Master Seo Apr 17. 2023

11. nhn클라우드-nks-sockshop 쇼핑몰


<1> 구성

<2> 배포

<3> User Accounts 

<4> Load test

<5> 정리



<1> 구성


https://github.com/microservices-demo/microservices-demo/blob/master/deploy/kubernetes/complete-demo.yaml


https://github.com/microservices-demo/microservices-demo/tree/master/deploy/kubernetes




<2> 배포


namespace는 반드시 모두 소문자 이여야 한다. 대문자는 안됨

숫자 포함은 가능


kubectl create namespace sockshop


k ns SockShop




https://microservices-demo.github.io/deployment/kubernetes-start.html


# 배포

#curl -O https://raw.githubusercontent.com/microservices-demo/microservices-demo/master/deploy/kubernetes/complete-demo.yaml

kubectl apply -f https://raw.githubusercontent.com/gasida/KANS/main/msa/sock-shop-demo.yaml


# 확인

kubectl get all -n sock-shop


# front-end 웹 접속 주소 확인

FRONTNIP=$(kubectl get pod -n sock-shop -l name=front-end -o jsonpath='{.items[0].status.hostIP}')


FRONTNPORT=$(kubectl get svc -n sock-shop front-end -o jsonpath={.spec.ports[0].nodePort})


echo -e "Front-end URL = http://$FRONTNIP:$FRONTNPORT"




<3> User Accounts 


https://microservices-demo.github.io/docs/user-accounts.html


user1

eve



<4> Load test


https://microservices-demo.github.io/docs/load-test.html


# (참고) Locust 툴 설명

docker run weaveworksdemos/load-test --help

Usage:

  runLocust.sh [ http://hostname/ ] OPTIONS


Options:

  -d  Delay before starting

  -h  Target host url, e.g. http://localhost/

  -c  Number of clients (default 2)

  -r  Number of requests (default 10)


Description:

  Runs a Locust load simulation against specified host.


# The syntax for running the load test container is

FRONTCIP=$(kubectl get svc -n sock-shop front-end -o jsonpath={.spec.clusterIP})

docker run --net=host weaveworksdemos/load-test -h $FRONTCIP -r 10 -c 2


docker run --net=host weaveworksdemos/load-test -h $FRONTCIP -r 13 -c 2

Locust file: /config/locustfile.py

Will run /config/locustfile.py against 10.98.146.227. Spawning 2 clients and 13 total requests.

[2022-02-23 21:33:03,811] k8s-m/INFO/locust.main: Starting Locust 0.7.5

[2022-02-23 21:33:03,812] k8s-m/INFO/locust.runners: Hatching and swarming 2 clients at the rate 5 clients/s...

[2022-02-23 21:33:04,219] k8s-m/INFO/locust.runners: All locusts hatched: Web: 2

[2022-02-23 21:33:04,221] k8s-m/INFO/locust.runners: Resetting stats

[2022-02-23 21:33:04,649] k8s-m/INFO/locust.runners: All locusts dead

[2022-02-23 21:33:04,650] k8s-m/INFO/locust.main: Shutting down (exit code 0), bye.


 Name                                                          # reqs      # fails     Avg     Min     Max  |  Median   req/s

--------------------------------------------------------------------------------------------------------------------------------------------

 GET /                                                              2     0(0.00%)      48      48      49  |      48    0.00

 GET /basket.html                                                   1     0(0.00%)      49      49      49  |      49    0.00

 DELETE /cart                                                       1     0(0.00%)      19      19      19  |      19    0.00

 POST /cart                                                         1     0(0.00%)      32      32      32  |      32    0.00

 GET /catalogue                                                     2     0(0.00%)      15      15      16  |      15    0.00

 GET /category.html                                                 1     0(0.00%)       4       4       4  |       4    0.00

 GET /detail.html?id=3395a43e-2d88-40de-b95f-e00e1502085b           0     0(0.00%)       0       0       0  |       0    0.00

 GET /detail.html?id=a0a4f044-b040-410d-8ead-4de0446aec7e           1     0(0.00%)      47      47      47  |      47    0.00

 GET /login                                                         2     0(0.00%)      28      27      30  |      27    0.00

 POST /orders                                                       2     0(0.00%)     118      74     163  |      74    0.00

--------------------------------------------------------------------------------------------------------------------------------------------

 Total                                                             13     0(0.00%)                                       0.00


Percentage of the requests completed within given times

 Name                                                           # reqs    50%    66%    75%    80%    90%    95%    98%    99%   100%

--------------------------------------------------------------------------------------------------------------------------------------------

 GET /                                                               2     49     49     49     49     49     49     49     49     49

 GET /basket.html                                                    1     49     49     49     49     49     49     49     49     49

 DELETE /cart                                                        1     19     19     19     19     19     19     19     19     19

 POST /cart                                                          1     32     32     32     32     32     32     32     32     32

 GET /catalogue                                                      2     16     16     16     16     16     16     16     16     16

 GET /category.html                                                  1      4      4      4      4      4      4      4      4      4

 GET /detail.html?id=a0a4f044-b040-410d-8ead-4de0446aec7e            1     47     47     47     47     47     47     47     47     47

 GET /login                                                          2     30     30     30     30     30     30     30     30     30

 POST /orders                                                        2    160    160    160    160    160    160    160    160    163

--------------------------------------------------------------------------------------------------------------------------------------------


# 수치를 늘려서 테스트 : PC 성능에 따라서 성공/실패

docker run --net=host weaveworksdemos/load-test -h $FRONTCIP -r 15 -c 2

docker run --net=host weaveworksdemos/load-test -h $FRONTCIP -r 20 -c 2

docker run --net=host weaveworksdemos/load-test -h $FRONTCIP -r 100 -c 2





모니터링

https://microservices-demo.github.io/deployment/monitoring-kubernetes.html


https://github.com/microservices-demo/microservices-demo/tree/master/deploy/kubernetes/manifests-monitoring





삭제

kubectl delete -f https://raw.githubusercontent.com/gasida/KANS/main/msa/sock-shop-demo.yaml






<5> 정리




감사합니다.





매거진의 이전글 10. nhn클라우드- nks -Travel Demo
브런치는 최신 브라우저에 최적화 되어있습니다. IE chrome safari