You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
다중 클라이언트 연결 웹 서버와 성능 테스트(Select Multiplexing): 201704147 이용재
다중 클라이언트 웹 서버 구현과 성능 테스트 (10점)
Select를 이용한 Multiplexing (4점)
import socket
import select
import os
import sys
def main(port):
serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
serversocket.bind(('', port))
print("listening...")
serversocket.listen()
input_list = [serversocket] # select를 통해 관찰할 리스트
while input_list:
input_ready, write_ready, except_ready = select.select(input_list, [], [])
for each in input_ready: # 관찰중인 input 리스트에 대한 부분
if each == serversocket:
(clientsocket, address) = serversocket.accept()
input_list.append(clientsocket)
else:
data = each.recv(1024).decode('utf-8') # 기존에 send_recv로 처리되어 있는 부분을 이렇게 변경해야 함
if data: # data가 존재하는 경우 실행
header = "HTTP/1.1 200 0K\r\n"
body = """
<!DOCTYPE html>
<html>
</html>
""" # body가 없으면 locust 측에서 error 발생
each.send((header + body).encode('utf-8'))
input_list.remove(each)
each.close()
else: # data가 없는 경우 실행
input_list.remove(each)
each.close()
if __name__ == "__main__":
port = 8881
main(port)
Locust를 이용한 서버 성능 테스트 결과 비교 작성 (6점)
Single Process
Single Process의 경우 RPS가 121.1이며, 10,000번의 요청을 했을 시 20%의 failure가 발생한다. 그리고 평균 응답시간은 28,878ms 이다.
Multi Process
Multi Process의 경우 RPS가 46.2이며, 10,000의 요청을 했을 시 6%의 failure가 발생한다. 그리고 평균 응답시간은 237,402ms 이다.
Multi Thread
Multi Thread의 경우 RPS가 99.3이며, 10,000번의 요청을 했을 시 13%의 failure가 발생한다. 그리고 평균 응답시간은 28,507ms 이다.
Select
Select의 경우 RPS가 213.4이며, 10,000번의 요청을 했을 시 11%의 failure가 발생한다. 그리고 평균 응답시간은 26,193ms 이다.
single process vs multi process vs multi thread vs select
Hatch Rate 100, 10000 Requests
single process
multi process
multi thread
select
Request
63,471
86,156
64,828
57,391
Request Per Second
121.2
46.2
99.3
213.4
Average Response time
28,878
237,402
28,507
26,193
failure
20%
4%
13%
1%
결과를 바탕으로 성능별로 나열해보자면 셀렉트, 싱글프로세스, 멀티스레드, 멀티프로세스 순이다. 가장 성능이 좋은 방식은 셀렉트이다.
The text was updated successfully, but these errors were encountered:
다중 클라이언트 연결 웹 서버와 성능 테스트(Select Multiplexing): 201704147 이용재
다중 클라이언트 웹 서버 구현과 성능 테스트 (10점)
Select를 이용한 Multiplexing (4점)
Locust를 이용한 서버 성능 테스트 결과 비교 작성 (6점)
Single Process
Multi Process
Multi Thread
Select
single process vs multi process vs multi thread vs select
The text was updated successfully, but these errors were encountered: