Skip to main content Link Menu Expand (external link) Document Search Copy Copied

created at 2023-03-28

API GateWay 선정

img

기존에 저는 nginx를 아래의 이유로 사용했어요.

  1. 통합 엔트리 포인트를 제공
  2. 리버스 프록시(백엔드 포인트 숨기기)
  3. 서비스 별 로드 밸런싱
  4. 높은 동시처리성능

1,2,3 번은 일반적인 Gateway 툴에서 제공하는 기능이구요. Nginx는 4번에 특화된 부분이라고 생각해서 사용하게 되었어요. 다르게 말하면, 높은 동시처리성능을 만족시키는 Gateway 라면 어떤것이든 상관없이 사용할 것입니다.

그러던 와중 Spring Cloud 에서는 Netflix Zuul 게이트웨이를 넷플릭스에서 기부받아서 지원하고 있더라구요. 그래서 제가 가장 중요하게 생각하는 동시처리성능에서의 차이를 비교해보기 위해서 아래의 원문을 가져와보았습니다. (reference : https://instea.sk/2015/04/netflix-zuul-vs-nginx-performance/)

API GateWay 처리성능비교

Via Nginx

Document Path: /sample.html
Document Length: 26650 bytes
 
Concurrency Level: 200
Time taken for tests: 52.366 seconds
Complete requests: 50000
Failed requests: 0
Total transferred: 1344700000 bytes
HTML transferred: 1332500000 bytes
Requests per second: 954.81 [#/sec] (mean)
Time per request: 209.465 [ms] (mean)
Time per request: 1.047 [ms] (mean, across all concurrent requests)
Transfer rate: 25076.93 [Kbytes/sec] received
 
Connection Times (ms)
 min mean[+/-sd] median max
Connect: 3 50 11.7 48 114
Processing: 37 159 11.9 160 208
Waiting: 36 159 11.9 160 207
Total: 40 209 10.4 209 256
 
Percentage of the requests served within a certain time (ms)
 50% 209
 66% 212
 75% 214
 80% 216
 90% 220
 95% 224
 98% 232
 99% 238
 100% 256 (longest request)

Requests per second: 954.81 (#/sec)

Via Zuul

Document Path: /sodik/sample.html
Document Length: 26650 bytes
 
Concurrency Level: 200
Time taken for tests: 50.080 seconds
Complete requests: 50000
Failed requests: 0
Total transferred: 1343550000 bytes
HTML transferred: 1332500000 bytes
Requests per second: 998.39 [#/sec] (mean)
Time per request: 200.322 [ms] (mean)
Time per request: 1.002 [ms] (mean, across all concurrent requests)
Transfer rate: 26199.09 [Kbytes/sec] received
 
Connection Times (ms)
min mean[+/-sd] median max
Connect: 2 16 7.9 16 126
Processing: 15 184 108.1 203 1943
Waiting: 13 183 105.9 202 1934
Total: 18 200 107.8 218 1983
 
Percentage of the requests served within a certain time (ms)
50% 218
66% 228
75% 235
80% 239
90% 254
95% 287
98% 405
99% 450
100% 1983 (longest request)

Requests per second: 998.39 (#/sec)

즉, Nginx(954)와 Zuul(998)은 동시성능(200-thread)에서 비교했을 떄, 큰 차이는 없음을 보여줍니다!

트랜드 비교

img

흠… 트랜드를 보았을 때 nginx를 사용하는게 좋겠지만, 저는 이전에 nginx.config 만질 때, 너무 복잡했던 기억이 있어서 Spring-boot 로 직접 수정이 가능한 Zuul 을 사용해볼꺼에요. 그런데 Zuul은 현재 deprecate 되어서 Zuul의 유지를 이어받은 Spring-Cloud-Gateway 를 사용할 것입니다.