camioljoyce
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # 使用JMeter 5工具做壓力測試 ### Step1: 進入[JMeter下載頁](https://jmeter.apache.org/download_jmeter.cgi)並下載apache-jmeter-5.4.1.zip檔案 ### Step2:把下載的檔案解壓縮,執行\bin目錄下的jmeter.bat ![](https://i.imgur.com/UDMwMeu.jpg) ### Step3: 打開後的UI如下圖,選擇功能列Options的選項,將介面語言改為繁體中文: ![](https://i.imgur.com/YisFoeb.jpg) ### Step4:首先在左側預設的測試計畫按滑鼠右鍵,選擇新增>Threads>執行緒群組,並輸入名稱(如:IIM執行緒群組)來建立一個測試群組。![](https://i.imgur.com/zPXhxLO.jpg) **接著在測試計畫上面按右鍵,選新增>設定元素>HTTP要求預設值,然後依序填上協定、主機名稱、port:** ![](https://i.imgur.com/8u56e3A.jpg) ![](https://i.imgur.com/ezxrsCm.jpg) **然後一樣在測試計畫上面按右鍵, 選新增>設定元素>HTTP Cookie管理員, 用來存放等等登入用的Cookie:** ![](https://i.imgur.com/9hUh9Hu.jpg) **然後在剛建立的IIM執行緒群組上面, 按右鍵選新增>取樣>HTTP要求, 建立一個登入用的請求:** ![](https://i.imgur.com/DOYnZU9.jpg) **填入需要的欄位:** **名稱:登入網站 HTTP要求:POST 路徑:/nii_iim/loginAction 參數新增使用者帳號密碼** ![](https://i.imgur.com/s5wEAXH.jpg) **在IIM執行緒群組上面, 按右鍵選新增>接聽>彙整報告:** ![](https://i.imgur.com/f9nay2m.jpg) ![](https://i.imgur.com/we6EgoJ.jpg) **在IIM執行緒群組上面, 按右鍵選新增>接聽>檢視結果樹:** ![](https://i.imgur.com/SwCmqAR.jpg) ![](https://i.imgur.com/4fjScKn.jpg) **這兩個用來裝我們等等跑的結果。** ### Step5:這時候我們可以先簡單測試一下是否有正常登入網站 **按下上方工具列的綠色箭頭開始跑:** **跑完後按下彙整報告,可以看到結果紀錄:** ![](https://i.imgur.com/7ePfDgK.jpg) **按下檢視結果樹,選擇回覆資料,可以看到已成功登入網站:** ![](https://i.imgur.com/KEVfOlA.jpg) ### Step6:因為網站只會登入一次,接著就可以使用其他功能,於是我們需要建立一個控制器: **在IIM執行緒群組上面按右鍵選新增>邏輯控制器>只有一次控制器,並且把剛剛的網站登入和彙整報告和檢視結果樹都拉進去控制器裡面,這樣一個執行緒就只會登入一次。** ![](https://i.imgur.com/0kKgVoh.jpg) ![](https://i.imgur.com/HI2HYf7.jpg) **登入網站之後,我們可以設定查詢某個功能,於是我們再按照上面的步驟來新增一個HTTP要求:** **填上網址和輸入要查詢的參數** ![](https://i.imgur.com/RCjOtKI.jpg) **然後一樣新增彙整報告和檢視結果樹:** ![](https://i.imgur.com/JZtFRlO.jpg) 最後我們來按照壓力測試需求來設定執行緒數量和迴圈次數: ![](https://i.imgur.com/QcAER14.jpg) **最後,按下綠色箭頭開始執行,就可以等著看結果了** ![](https://i.imgur.com/vvn2EFm.jpg) ![](https://i.imgur.com/q9RbQxI.jpg) **如果是需要大量執行緒同時跑測試的話,可以新增>設定元素>HTTP標頭管理員** **打開網頁,使用開發者模式,選Network,勾選Preserve log,避免log被洗掉,然後開始登入網站,拿到Cookie:** ![](https://i.imgur.com/Oo5Jwjw.jpg) **把這段Cookie新增到剛新增的HTTP標頭管理員** ![](https://i.imgur.com/3hytBa6.jpg) **這樣就可以不用登入,直接測試查詢頁面了。** --- **另外可以把統計報告存成csv檔,變成excel輸出** ![](https://i.imgur.com/8AzVXsS.jpg) ![](https://i.imgur.com/K0eIpi6.jpg) :::info **Elapsed: TTLB** - time to last byte **Latency: TTFB** - time to first byte **Connect:** time to connect to server, includes SSL Handling ::: Jmeter聚合報告: #samples:總請求數(samples樣本個數)(number of requests) Throughput 吞吐量(Request/Sec) 每秒多少請求 Average 平均響應時間 Received KB/sec :每秒從服務器端接收到的數據量(每秒發送多少字節 ) Sent KB/sec :每秒向服務器發送數據量(每秒發送多少字節 ) 其他: thread:請求併發數 total time:請求持續執行的時間(實際持續時間可能大於填寫持續時間) total time = 請求測試結束時間 - 請求測試開始時間 (最後一個線程啓動的時間+最後一個線程持續的時間-第一個線程啓動的時間) 請求測試結束時間 = MAX(最後1個請求啓動時間timeStamp + Elapsed Time) 請求測試開始時間 = MIN(第1個請求啓動時間timeStamp) 計算: Throughput=(#sample樣本數)/(最後一個線程啓動的時間+最後一個線程持續的時間-第一個線程啓動的時間) =(number of requests)/total time=Jmeter(#Samples)/total time Average=所有請求的響應時間之和/總請求數= Jmeter sum(elapsed)/#Samples (所有sample樣本響應時間總和/Samples樣本個數) Received KB/sec=所有的相同請求的bytes總和 / 1024 / 請求持續運行的時間=sum(bytes)/1024/total time Sent KB/sec =所有的相同請求的sentBytes總和 / 1024 / 線程持續運行的時間=sum(sentBytes)/1024/total time =================== Throughput (TPS)=Jmeter(#Samples)/total time Average= Jmeter sum(elapsed)/#Samples TPS:每秒處理的事務數,jmeter的Throughput爲吞吐率(請求數/秒),在加了事務控制器後,TPS=Throughput 宏觀上:TPS=併發數/響應時間,jmeter的Throughput = (number of requests) / (total time) ,即 Throughput =(sample樣本數)/(最後一個線程啓動的時間+最後一個線程持續的時間-第一個線程啓動的時間) 可以這樣理解這個公式:絕對的併發是不存在的,請求發出的時間總有先後,絕對的TPS也是無法計算的,統計的角度看,服務器處理請求總數/花費的時間即是TPS,這也是 爲什麼需要不斷增大用戶數來尋找服務器的最大TPS的原因 ###### tags: `壓力測試`、`JMeter 5`

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully