updated 2012.09.06

이번엔 node.js를 클러스터 모듈을 이용해서 실행해봤다. 확실히 빨라졌다. 초당 요청처리량 vert.x와 거의 비슷하다. 단지 차이가 있다면 top으로 지켜볼 때 node.js는 프로세스 ID가 가상 코어 갯수만큼 뜬다. 즉 16개가 뜨고 평균 CPU 사용량은 40% 정도다. 하지만 Vert.x는 프로세스 ID는 한개만 뜬다. 그리고 CPU 사용량은 140% 정도다.

코드를 꼭 http://nodejs.org/api/cluster.html#cluster_cluster 이런식으로 짜야만 서버 리소스를 제대로 활용할 수 있고 여러 프로세스로 나뉘어 실행해야하는 node.js 보다는 vert.x가 더 쓰기 편하고 성능도 결코 node.js에 뒤쳐지지 않는것 같다.

===============================================

빠르지 않다. 둘이 비슷하다. node test.js로 실행할 때는 CPU를 한개만 사용한다. top으로 지켜봤더니 CPU가 100%를 넘지 못한다. vertx run Test.java로 실행했을 때는 150%를 넘어서 돌고 있다. vertx는 JVM을 사용하니까 JVM이 CPU 갯수가 몇개든 다 활용해주는거고 node는 한개만 사용하는듯 한데.. node에 CPU를 전부 다 사용하도록 설정할 수 있는 옵션이 있던가.. 아님 CPU 갯수만큼 node test.js를 실행해줘야 하던가.. 모르겠네;;

대충 2배니까 대충 비슷하다 치고 대충 테스트 끝.

===============================================

뭔가 이유가 있을 것 같은데 아직 모르겠네...

[gist id=3633727]

테스트 코드는 2byte 문자를 보내는 아주 단순한 웹 서버. 이 웹 서버로 10명의 동접자가 보내는 요청 5만개를 얼마나 빠른 시간안에 처리하느냐를 테스트 해보기로 결정.

테스트 클라이언트는 아파치 벤치로.

ab -t 10 -c 10 -n 50000 http://테스트할서버:포트/

최대 10초 동안 10개의 동접자가 총 5만개 요청을 보냄.

서버 사양은

  • 물리 CPU 2개.
  • 물리 CPU당 코어 갯수 4개.
  • 가상 코어 총 갯수 16개.
  • CPU 속도는 2.27GHz
  • 메모리는 16G

테스트 결과.

node.js

Server Software:
Server Hostname: xxxx
Server Port: yyyy

Document Path: /
Document Length: 2 bytes

Concurrency Level: 10
Time taken for tests: 6.769 seconds
Complete requests: 50000
Failed requests: 0
Write errors: 0
Total transferred: 3300000 bytes
HTML transferred: 100000 bytes
Requests per second: 7386.61 [#/sec] (mean)
Time per request: 1.354 [ms] (mean)
Time per request: 0.135 [ms] (mean, across all concurrent requests)
Transfer rate: 476.09 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 2
Processing: 0 1 0.5 1 11
Waiting: 0 1 0.5 1 11
Total: 1 1 0.5 1 11

Percentage of the requests served within a certain time (ms)
50% 1
66% 1
75% 1
80% 1
90% 1
95% 1
98% 2
99% 2
100% 11 (longest request)

vert.x

Server Software:
Server Hostname: xxxx
Server Port: yyyy

Document Path: /
Document Length: 2 bytes

Concurrency Level: 10
Time taken for tests: 3.865 seconds
Complete requests: 50000
Failed requests: 0
Write errors: 0
Total transferred: 3300000 bytes
HTML transferred: 100000 bytes
Requests per second: 12935.92 [#/sec] (mean)
Time per request: 0.773 [ms] (mean)
Time per request: 0.077 [ms] (mean, across all concurrent requests)
Transfer rate: 833.76 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 0 1 1.0 0 49
Waiting: 0 1 1.0 0 49
Total: 0 1 1.0 0 49
WARNING: The median and mean for the processing time are not within a normal deviation
These results are probably not that reliable.
WARNING: The median and mean for the waiting time are not within a normal deviation
These results are probably not that reliable.
WARNING: The median and mean for the total time are not within a normal deviation
These results are probably not that reliable.

Percentage of the requests served within a certain time (ms)
50% 0
66% 1
75% 1
80% 1
90% 2
95% 2
98% 3
99% 4
100% 49 (longest request)

대략 2배가 차이나는데 많게는 어떤때는 3개 가까이 차이 날때도 있다. 아마도 node test.js를 실행했을 때는 물리 CPU를 1개밖에 사용하지 않는것 같고 vertx run Test.java를 실행했을 때는 물리 CPU 2개를 모두 사용하는 것 같다.

정말 그래서 생긴 차이라면 사실 이 둘의 성능은 비슷하다고 볼 수 있는거 아닌가 싶다.