「喵咪軟件推薦(2)」全球服務器測速工具speedtest-cli


前言

在上一篇章中給大家介紹了全球國家信息國旗區號等一些全球國家新的庫,今天也給大家介紹一個和全球化有關的軟件,它的名字叫做speedtest-cli,直譯成中文就是速度測試命令,那麼究竟是測試什麼速度呢? -> 請緊張繼續往下看

附上:

喵了個咪的博客:w-blog.cn

speedtest-cli GitHub :https://github.com/sivel/speedtest-cli

1.speedtest-cli介紹以及安裝


使用場景

有一天領導走到你旁邊說:”小王啊! 我們要在海外部署服務器了 你看我們現在國內的服務器在那些國家使用起來還不錯啊 我們主要客戶是歐洲和東南亞的客戶節點選在哪裡會比較好啊! ” 這個時候小王一臉矇蔽

那麼問題來了,怎麼才能知道現在的服務器到全國各地的延遲怎麼樣,到全球各個國家的延遲又怎麼樣呢,這個時候你就需要 speedtest-cli 來幫你解決燃眉之急了

安裝

speedtest-cli由python編寫,主要功能是對本節點對全球各個國家之間的延遲進行測試,延遲以及上行和下行帶寬,安裝起來也特別容易speedtest-cli 支持 Python 2.4-3.5 版本

使用pip / easy_install安裝如下

<code>pip install speedtest-cli

easy_install speedtest-cli/<code>

也可以從git上去安裝最新版本

<code>pip install git+https://github.com/sivel/speedtest-cli.git

git clone https://github.com/sivel/speedtest-cli.git
python speedtest-cli/setup.py install/<code>

然後運行speedtest-cli即可使用,默認會找到speedtest-cli服務器中最近的節點進行測試,筆者服務器在新加坡得到結果如下

<code>Retrieving speedtest.net configuration...
Testing from Alibaba (你自己的IP)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by SGIX (Singapore) [7.42 km]: 1.294 ms
Testing download speed................................................................................
Download: 532.13 Mbit/s
Testing upload speed....................................................................................................
Upload: 5.76 Mbit/s/<code>


2. 使用

speedtest-cli有幾個常用命令一個是speedtest-cli —list 它可以獲取出很多條如下的內容

<code> 7009)    SuperInternet (Singapore, Republic of Singapore) [7.42 km]
↑ ↑ ↑ ↑ ↑

服務器ID 運營商 城市 國家 和你本機的距離/<code>

然後我們可以通過 speedtest-cli --server=服務器IP --share 我們就可以開始測速了 這裡選擇一臺中國的服務器加上grep進行篩選

<code>speedtest-cli --list | grep China

10192) NanningTelecom (Nanning, China) [2434.50 km]
10305) GX-Telecom (Nanning, China) [2434.50 km]
5674) GX-Unicom (Nanning, China) [2434.50 km]
2993) Website Solution Limited (Hong Kong, China) [2578.61 km]
10267) Interoute VDC (Hong Kong, China) [2578.61 km]
1536) STC (Hong Kong, China) [2578.61 km] /<code>

然後使用 speedtest-cli --server=10305 --share測試新加坡到南京的速度結果如下:

<code>Retrieving speedtest.net configuration...
Testing from Alibaba (47.88.240.222)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by GX-Telecom (Nanning) [2434.50 km]: 133.62 ms
Testing download speed................................................................................
Download: 521.78 Mbit/s
Testing upload speed....................................................................................................
Upload: 5.84 Mbit/s
Share results: http://www.speedtest.net/result/6082037976.png/<code>

應為是阿里服務器下行帶寬是不限制的可以看到500MB很是給力,延遲有133.62毫秒也很正常,上行帶寬可能達到服務器限制最大值所以中國到新加坡網絡情況還是比較好的

並且可以通過訪問最後面的http://www.speedtest.net/result/6082037976.png 獲取你本次測試的結果圖片

3 總結

對於還在糾結服務器需要選擇到哪裡,需要海外部署服務器或者海外有用戶反映比較慢的童鞋,我相信speedtest-cli可以幫助到你們!

注:筆者能力有限有說的不對的地方希望大家能夠指出,也希望多多交流!


分享到:


相關文章: