python 으로 로드 테스트가 가능하고 ngrinder 보다 굉장히 심플하고 가볍기도 해서 사용해보았다.
1. 스크립트 작성
class MatchOrderTasks(HttpUser):
wait_time = between(1, 2)
@task
def start(self) :
type = self.get_type()
id = uuid.uuid4().hex
user_id = random.randint(0, 0x7feabb849210)
request = self.get_start_request(id, user_id, type)
self.client.post('/v1/start', data=json.dumps(request), headers={'Content-Type':'application/json'})
if user_id % 4 == 0:
self.accept(id)
return None
if user_id % 5 == 0:
self.stop(id)
2. Docker build
FROM locustio/locust
WORKDIR /mnt/locust/
ADD stress.py ./
ENTRYPOINT ["locust", "-f", "./stress.py"]
3. Locust Deploy
master
apiVersion: "apps/v1"
kind: "Deployment"
metadata:
name: locust-master
labels:
name: locust-master
spec:
replicas: 1
selector:
matchLabels:
app: locust-master
template:
metadata:
labels:
app: locust-master
spec:
containers:
- name: locust-master
image: locustio/locust
env:
- name: LOCUST_MODE
value: master
- name: TARGET_HOST
value: http://{TARGET_HOST}
ports:
- name: loc-master-web
containerPort: 8089
protocol: TCP
worker
apiVersion: "apps/v1"
kind: "Deployment"
metadata:
name: locust-worker
labels:
name: locust-worker
spec:
replicas: 3
selector:
matchLabels:
app: locust-worker
template:
metadata:
labels:
app: locust-worker
spec:
containers:
- name: locust-worker
image: locustio/locust
env:
- name: LOCUST_MODE
value: worker
- name: LOCUST_MASTER
value: locust-master
- name: TARGET_HOST
value: http://{TARGET_HOST}
ETC
'server' 카테고리의 다른 글
org.apache.http.NoHttpResponseException {{host}}:443 failed to respond (0) | 2020.08.12 |
---|---|
멀티모듈에 한 방으로 적용되는 application.yml (0) | 2020.06.08 |
tcpdump mtr (0) | 2020.05.15 |
모든 API 엔드포인트에 공통 파라미터가 필요하다. (0) | 2020.04.30 |
어째서 엔티티가 계속 업데이트 되는가.. (0) | 2019.06.28 |
댓글