Dropboxlike上傳區塊大小效能測試

這次測試的環境是

  • 檔案大小:682.3MB
  • Android 用戶端硬體:小米手機3
  • 伺服器的硬體:macbook pro 2015, OS X 10.12.3
  • 路由器:小米路由

手機的執行畫面如下:


首先測試區塊大小是 1MB 的情況下,Android 輸出的Log:

  • 02-22 15:07:55.901 23790-23976/com.lwfd.dropboxlike D/SeafConnection: getUploadSessionStart POST: https://192.168.31.70:80/1/files/upload_session/start
  • 02-22 15:11:29.899 23790-23976/com.lwfd.dropboxlike D/SeafConnection: getUploadSessionFinish POST: https://192.168.31.70:80/1/files/upload_session/finish

Dropboxlike-Server 的執行畫面:

說明:左邊紅框,可以看到檔案的每一個offset 間格 1MB, 右邊看到每一個 request  需要花 140 ~200ms.

  • Session Size=1MB
  • Spent Time=3分34秒
  • request buffer size=default.

測完 1MB, 直接加一個數字0 測看看 10MB, Andriod Log:

  • 02-22 15:13:42.337 30685-30954/com.lwfd.dropboxlike D/SeafConnection: getUploadSessionStart POST: https://192.168.31.70:80/1/files/upload_session/start
  • 02-22 15:15:57.548 30685-30954/com.lwfd.dropboxlike D/SeafConnection: getUploadSessionFinish POST: https://192.168.31.70:80/1/files/upload_session/finish

 

Dropboxlike-Server 的執行畫面:

Session Size=10MB
Spent Time=2分15秒
request buffer size=default.


接著,測試看看 20MB, 程式會掛掉,調整了 request.bufferSize 參數為 1KB, 還是一樣會掛掉,可能是跟 20MB無緣,再測試看看 10MB, 再加上 request.bufferSize=1024, Android Log:

  • 02-22 15:19:33.223 5060-5280/com.lwfd.dropboxlike D/SeafConnection: getUploadSessionStart POST: https://192.168.31.70:80/1/files/upload_session/start
  • 02-22 15:22:00.859 5060-5280/com.lwfd.dropboxlike D/SeafConnection: getUploadSessionFinish POST: https://192.168.31.70:80/1/files/upload_session/finish

測完結果,慢了12秒:

  • Session Size=10MB
  • Spent Time=2分27秒
  • req buffer size=1K

所以,後面的測試都不加 bufferSize 使用 request 裡預設值,預設值是什麼,我也不清楚,我是「囫圇吞棗」&「不求甚解」的愛好者,這問題自動跳過。


測看看 4MB

  • 02-22 15:28:19.632 13246-13375/com.lwfd.dropboxlike D/SeafConnection: getUploadSessionStart POST: https://192.168.31.70:80/1/files/upload_session/start
  • 02-22 15:30:31.248 13246-13375/com.lwfd.dropboxlike D/SeafConnection: getUploadSessionFinish POST: https://192.168.31.70:80/1/files/upload_session/finish

 

Dropboxlike-Server 的執行畫面:

說明:一個server side request 大需需要 600ms 左右。原本以為 10MB 是最佳的大小,因為減少了與伺服器間斷線還有重新連線的封包,沒想到 4MB整體效能比10MB好。

  • Session Size=4MB
  • Spent Time=2分12秒
  • request buffer size=default.
  • 每秒傳送速度 5.17MB/Sec

 


測試看看 6MB, 預期應該會比 4MB 好:

  • 02-22 15:34:49.249 13246-13447/com.lwfd.dropboxlike D/SeafConnection: getUploadSessionStart POST: https://192.168.31.70:80/1/files/upload_session/start
  • 02-22 15:37:02.646 13246-13447/com.lwfd.dropboxlike D/SeafConnection: getUploadSessionFinish POST: https://192.168.31.70:80/1/files/upload_session/finish

 

Dropboxlike-Server 的執行畫面:

說明:一個server side request 大約需要 1秒。測試結果整體效能和4MB一樣。

  • Session Size=6MB
  • Spent Time=2分13秒
  • request buffer size=default.

 


 

測試 3MB:

  • 02-22 15:39:20.324 25932-26183/com.lwfd.dropboxlike D/SeafConnection: getUploadSessionStart POST: https://192.168.31.70:80/1/files/upload_session/start
  • 02-22 15:41:34.928 25932-26183/com.lwfd.dropboxlike D/SeafConnection: getUploadSessionFinish POST: https://192.168.31.70:80/1/files/upload_session/finish

結果和4MB 差不多,但比 4MB 慢了2秒多,差異不大:

  • Session Size=3MB
  • Spent Time=2分14秒
  • request buffer size=default.

測試看看 2MB:

  • 02-22 15:44:34.124 32244-32418/com.lwfd.dropboxlike D/SeafConnection: getUploadSessionStart POST: https://192.168.31.70:80/1/files/upload_session/start
  • 02-22 15:46:52.743 32244-32418/com.lwfd.dropboxlike D/SeafConnection: getUploadSessionFinish POST: https://192.168.31.70:80/1/files/upload_session/finish

結果和4MB 差不多,但比 4MB 慢了6秒,差異不大:

  • Session Size=2MB
  • Spent Time=2分18秒
  • request buffer size=default.

 

相關文章

寫留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *