性能壓測時,併發壓力增加,系統響應時間和吞吐量如何變化

{"type":"doc","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"性能測試"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"性能測試是性能優化的前提和基礎,也是性能優化結果的檢查和度量標準。不同視角下的網站性能有不同的標準,也有不同的優化手段。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"主觀視角:用戶感受到的性能"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"加載頁(先文字後圖片)"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"客觀視角:性能指標衡量的性能"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"做性能優化的時候,一方面提高性能指標,另一方面要考慮到提高用戶的主觀感受(可以利用異步操作)。架構師訓練營不介紹主觀視角"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"性能測試指標"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"相應時間 RT"},{"type":"text","text":", Response Time"},{"type":"text","marks":[{"type":"strong"}],"text":":"},{"type":"text","text":"用戶感受到的時間(客戶端視角)。應用系統從發出請求開始到收到最後響應數據所需要的時間。直觀的反映了系統的快慢"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"併發數:"},{"type":"text","text":"系統能夠同時處理請求的數目,系統的負載特性。對於網站而言,併發數即系統併發用戶數,指同時提交請求的用戶數目。注意與在線用戶數(當前登錄系統的用戶數)和系統用戶數(可能訪問系統的總用戶數)的區別。一般來說,併發數不會太大,淘寶雙十一高峯併發數可能是百萬級別,可能同時在線數達到億級,用戶數可能超過十億。"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"吞吐量:"},{"type":"text","text":"單位時間內系統處理的請求數量,系統的處理能力。對於網站,請求數/秒,頁面數/秒,訪問人數/天,處理的業務數/小時"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"TPS, Transactions Per Second 每秒事務數"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"性能計數器:"},{"type":"text","text":"描述服務器或操作系統性能的數據指標,包括 System Load、對象與線程數、內存使用、CPU 使用、磁盤與網絡 I/O 等指標。"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"其他常用指標:"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"RPS, Request Per Second:每秒請求數"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"CPS, Codes Per Second:HTTP 返回碼每秒"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"PV, Page View:頁面瀏覽量"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"UV, Unique Vistor:獨立訪問者"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"IP, Internet Protocal:獨立 IP 數"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"IOPS, Input/Output Operations Per Second 磁盤"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"吞吐量 = ( 1000 / 響應時間 ms) × 併發數"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"吞吐量 Throughput 的討論需要有時間單位,一般採用 Bytes/Second、Pages/Second 和 Request/Second 等單位。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Bytes/Second 和 Pages/Second 表示的吞吐量,受網絡設置、服務器架構、應用服務制約"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Request/Second 表示的吞吐量,受應用服務器和應用本身的制約"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"不同併發用戶數場景下,即使系統具有相近的吞吐量,但是得到的系統性能瓶頸也不一樣。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"比如 100 個併發用戶,每用戶每隔 1 秒發出一個 Request 和 1000 個併發用戶,每隔 10 秒發出一個 Request,兩個場景有相同的吞吐量 100 Request/Second,但是兩個場景所佔用的資源不一樣,性能拐點也肯定不一樣。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/64/64b46f5c5bf0a8eafac37e39527e8602.png","alt":null,"title":"","style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"性能測試方法"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/cb/cbb31c18a2833bd790338dd3374ce3a4.png","alt":null,"title":"","style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"性能測試:"},{"type":"text","text":"以系統設計初期規劃的性能指標爲預期目標,對系統不斷施加壓力,驗證系統在資源可接受範圍內,是否能達到性能預期"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"負載測試:"},{"type":"text","text":"對系統不斷增加併發請求以增加系統壓力,直到系統的某項或多項性能指標達到安全臨界值,如某種資源已經呈飽和狀態,這時候繼續對系統施加壓力,系統的處理能力不但不能提高,反而會下降。"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"壓力測試:"},{"type":"text","text":"超過安全負載的情況下,對系統繼續施加壓力,知道系統崩潰或不能再處理任何請求,一次獲得系統最大壓力承受能力。"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"穩定性測試:"},{"type":"text","text":"在特定硬件、軟件、網絡環境條件下,給系統加載一定業務壓力,是系統運行較長一段時間,以此檢測系統是否穩定。在生產環境,請求壓力是不均勻的,呈波浪特性,因此爲了更好的模擬生產環境,穩定性測試也應不均勻的對系統施加壓力。"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/d6/d64da9de2e53edfbd7258e4d92c3e489.png","alt":null,"title":"","style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"究竟部署多少臺服務器(資源)比較合適?是架構師需要考慮的一個決策,找到性能、價格的平衡點。架構師要清醒的知道,決策的依據到底是什麼,可能的代價是什麼,是否能夠承擔這個責任……"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"空閒區間:"},{"type":"text","text":"系統併發用戶數比較少,吞吐量也低,系統處於空閒狀態"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"線性增長區間:"},{"type":"text","text":"系統整體負載不大,隨着併發用戶數增長,吞吐量也會隨之線性增長"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"拐點:"},{"type":"text","text":"系統併發用戶數進一步增長,系統處理能力趨於飽和,每個用戶的響應時間逐漸變長;系統整體吞吐量不會隨着併發用戶數增長而繼續線性增長。"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"過飽和區間:"},{"type":"text","text":"系統併發用戶數繼續增長,系統處理能力達到過飽和狀態;如果繼續增加併發用戶數,最終所有用戶的響應時間會變得無限長;系統整體吞吐量會降爲零,系統處於被壓垮的狀態。"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/09/090869bca529d6cb5e1253bb403ca6b6.png","alt":null,"title":"","style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Performance Testing Methodology, Quest Soft, 2005"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/a3/a3789ad63c8f9925a583ff4d32c78db9.png","alt":null,"title":"","style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在 TPS 增加的過程中,響應時間一開始會處在較低的狀態,也就是在 A 點之前。接着響應時間開始有些增加,直到業務可以承受的時間點 B,這時 TPS 仍然有增長的空間。再接着增加壓力,達到 C 點時,達到最大 TPS。我們再接着增加壓力,響應時間接着增加,但 TPS 會有下降(請注意,這裏並不是必然的,有些系統在隊列上處理得很好,會保持穩定的 TPS,然後多出來的請求都被友好拒絕)。最後,響應時間過長,達到了超時的程度。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"——《02丨性能綜述:TPS和響應時間之間是什麼關係?》 性能測試實戰30講"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"通常從兩個層面定義性能場景的需求指標:業務指標和技術指標。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"所有的技術指標都是在有業務場景的前提下制定的,而技術指標和業務指標之間也要有詳細的換算過程。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章