溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

Zuul & Spring Cloud Gateway & Linkerd性能對比是怎樣的

發(fā)布時間:2021-12-02 16:03:50 來源:億速云 閱讀:492 作者:柒染 欄目:云計算

本篇文章為大家展示了Zuul & Spring Cloud Gateway & Linkerd性能對比是怎樣的,內(nèi)容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細(xì)介紹希望你能有所收獲。

動機

已經(jīng)不止一次看到“Spring Cloud Gateway性能比Zuul更差”的言論了,不少人人云亦云,來問我,既然如此,那Spring官方還開發(fā)Spring Cloud Gateway干嘛?難道僅僅是為了支持Zuul 1.x不支持的長連接、Web Socket嗎?

故而寫篇博客,糾正一下大家的錯誤觀點。

開端

網(wǎng)上搜索了一下,說Spring Cloud Gateway性能比Zuul差的言論來自:http://www.servicemesh.cn/?/article/45

作者使用 ab 進(jìn)行benchmark,操作非常標(biāo)準(zhǔn)。從結(jié)果來看,確實Spring Cloud Gateway比Zuul差了一大截。

但,讓我們打開官方的Issue:Throughput problems when compared with Netflix Zuul and Nginx ,里面官方人員回答道:

reactor-netty has issues with http 1.0 and hence ab. reactor/reactor-netty#21

不妨跟蹤到reactor/reactor-netty#21 ,看看說了啥:

As discussed recently about the issue raised on https://jira.spring.io/browse/SPR-14964, a very simple ab-n1-c1http://localhost:8082/items/10 on Spring + Reactor Netty based server block forever likely because Reactor Netty does not support HTTP 1.0.

里面說了,Reactor Netty不支持HTTP 1.0,而Spring Cloud Gateway依賴了 reactor-netty 。

也就是說——由于reactor-netty的bug,使用 ab 壓測結(jié)果并不準(zhǔn)確!

正確姿勢

官方建議使用 wrk 進(jìn)行benchmark測試。不僅如此,官方人員還十(喪)分(心)貼(?。┬模瘢┑貏?chuàng)建了一個benchmark的項目:spring-cloud-gateway-bench ,其中對比了:

  • Spring Cloud Gateway

  • Zuul

  • Linkerd

三者的性能。

思路非常簡單:static 項目是一個使用Go語言編寫的簡單服務(wù)器;然后分別使用Gateway/Zuul/Linkerd來代理該服務(wù)的端點,并對比。

最終結(jié)果:

組件RPS(request per second)
Spring Cloud GatewayRequests/sec: 32213.38
ZuulRequests/sec: 20800.13
LinkerdRequests/sec: 28050.76

從結(jié)果可知,Spring Cloud Gateway的RPS是Zuul1的1.6倍!比Linkerd性能還好!

  • 本文的Zuul,指的是Zuul 1.x,是一個基于阻塞io的API Gateway。

  • Spring Cloud Gateway是一個很有前途的項目,上手簡單,功能也比較強大。

  • Linkerd也是一個非常有前途的項目,是基于Scala實現(xiàn)的、目前市面上僅有的生產(chǎn)級別的Service Mesh(其他諸如Istio、Conduit暫時還不能用于生產(chǎn))。

  • Zuul已經(jīng)發(fā)布了Zuul 2.x,基于Netty,也是非阻塞的,支持長連接,但Spring Cloud暫時還沒有整合計劃。

上述內(nèi)容就是Zuul & Spring Cloud Gateway & Linkerd性能對比是怎樣的,你們學(xué)到知識或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識儲備,歡迎關(guān)注億速云行業(yè)資訊頻道。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI