rancher 自帶了一套網絡方案,能夠實現跨機器的docker容器互聯。其原理大體是:在每一個機器上經過docker啓動一個路由容器,將docker容器啓動時的ip定義爲10.42網段,並在iptables中將10.42網段的請求轉發到路由進程的監聽端口,進行udp的封裝和解封。這麼看來其原理與flannel同樣都是隧道技術,都是經過一個程序進行封包解包,並引導docker啓動容器時指定相應的ip。但flannel的數據存在etcd,而rancherSDN的數據存儲暫未了解(但確定是存在內存中)。下面對rancherSDN的網絡性能作一次測試。redis
對比:物理機進程。
場景:docker
1.redis部署在物理機上,markbench部署在另外一臺物理機的docker容器中(hostnetwork) 2.redis部署在docker上(屬於rancher的sdn),markbench部署在另外一臺物理機的docker中(屬於rancher的sdn)。
測試:網絡
1.1000個併發 1000000個請求 8byte數據包 2.1000個併發 1000000個請求 1024byte數據包
測試1
場景1:併發
Concurrency Level: 1000--??? Time taken for tests: 14738.712 ms--???? Complete Requests: 1000000--?????? Failed Requests: 0--???? Requests per second: 70381.16--QPS Time per request: 14.208348 ms--???? Time per request: 0.014208348 ms (across all concurrent requests)--??????????? Shortest request: 0.210504 ms--???? Percentage of the requests served within a certain time (ms) 50% 11.902441--50% ????0.005703???? 66% 12.081795 75% 12.233685 80% 12.335639 90% 12.679234 95% 13.357562 98% 14.547652 99% 17.011213 100% 3390.3135 (longest request)--?????```
場景2:負載均衡
Concurrency Level: 1000--??? Time taken for tests: 41545.566 ms--???? Complete Requests: 1000000--?????? Failed Requests: 0--???? Requests per second: 37853.703--QPS Time per request: 26.417492 ms--???? Time per request: 0.026417492 ms (across all concurrent requests)--??????????? Shortest request: 0.263888 ms--???? Percentage of the requests served within a certain time (ms) 50% 20.311712--50% ????0.005703???? 66% 21.991657 75% 22.531752 80% 22.833311 90% 23.901358 95% 26.956127 98% 35.04501 99% 219.7134 100% 22636.861 (longest request)--?????
測試2:
場景1:工具
Concurrency Level: 1000--??? Time taken for tests: 15144.447 ms--???? Complete Requests: 1000000--?????? Failed Requests: 0--???? Requests per second: 67796.72--QPS Time per request: 14.749976 ms--???? Time per request: 0.014749976 ms (across all concurrent requests)--??????????? Shortest request: 0.239347 ms--???? Percentage of the requests served within a certain time (ms) 50% 13.554401--50% ????0.005703???? 66% 13.735824 75% 13.886956 80% 13.990395 90% 14.687311 95% 15.511463 98% 18.912176 99% 21.210245 100% 702.1307 (longest request)--?????
場景2:性能
Concurrency Level: 1000--??? Time taken for tests: 35280.426 ms--???? Complete Requests: 1000000--?????? Failed Requests: 0--???? Requests per second: 32202.309--QPS Time per request: 31.053675 ms--???? Time per request: 0.031053673 ms (across all concurrent requests)--??????????? Shortest request: 0.314267 ms--???? Percentage of the requests served within a certain time (ms) 50% 25.674334--50% ????0.005703???? 66% 27.830894 75% 29.81296 80% 30.791946 90% 33.643417 95% 39.105713 98% 54.156647 99% 236.9922 100% 20131.455 (longest request)--?????
使用rancher的sdn網絡,性能表現比較差,而且測試過程當中因爲併發量太大程序還跑出了很多超時的異常。雖然benchmark端不是放在同一個地方進行的測試,可是能夠明顯看到相比物理機端的差距(相比之下flannel的損耗狀況會改善一些)。固然,使用rancher對docker容器進行編排的時候,能夠指定任何想要的網絡方式如:bridge(flannel採用的方式),host,managed(rancher SDN)。測試
因此拋開sdn,rancher依然是一個很好的docker編排工具。它已經實現了多套環境的切換,多種結構的容器編排(按機器和按項目,k8s的編排思想與之有出入,因此沒有這個功能),項目容器的伸縮,機器/容器的監控,對容器的啓動參數也支持得很全面。若是rancherSDN能夠作的更好,結合rancher的loadbalance功能,就能夠規範地給服務進行負載均衡了。spa