Pre-configuration
JMeter
- Download JDK and configure Java Environment Variables
- Download JMeter zip file for windows.
- Unzip JMeter in certain dir, for example, D:\apache-jmeter-3.1
- Run JMeter
- Open cmd.exe > change direction to D:\apache-jmeter-3.1\bin > jmeter > Enter.
- Or open folder by GUI > D:\apache-jmeter-3.1\bin > Double click jmeter.bat.
JMeter Plug-ins
- Download JMeter Plugins Manager.
- Copy and paste it into D:\apache-jmeter-3.1\lib\ext.
- Run Jmeter > Options > you will see Plugins Manager.
- Install Throughput Sharing Timer
- Plugin Manager > Throughput Sharing Timer, PerfMon, jpgc-Standard Set > Apply changes and Restart JMeter.
- Test Plan > Add > Threads(Users) > Ultimate Thread Group.
- Right click Ultimate Thread Group > Add > Listener > PerfMon.
- Click jp@gc - PerfMon Metrics Controller > Add Row
| Host/IP | Port | Metrics to collect | Metrics parameter |
| ---------- | ----- | ----------------------- | ------------------------ |
| wechat-dev2.vod309.com | 39800(you defined in serverAgent) | CPU | combined |
| wechat-dev2.vod309.com | 39800(you defined in serverAgent) | Memory | usedperc |
| wechat-dev2.vod309.com | 39800(you defined in serverAgent) | Network/IO | iface=eth0:unit=mb:bytessent |
| wechat-dev2.vod309.com | 39800(you defined in serverAgent) | Disks/IO | queue |
PerfMonServerAgent
- Download PerfMonServerAgent, unzip and copy the folder to certain directory in your server.
- Start agent: sudo sh ./startAgent.sh --udp-port 0 --tcp-port 39800
JMeter scripts
- Right click "Test Plan" > Add > Threads(Users) > jp@gc - Ultimate Thread Group.
- Right click "jp@gc - Ultimate Thread Group" > Add > Config Element > HTTP Header Manager.
- Name: Content-Type
- Value: application/json;charset=utf-8
- If requests has the same request parameter, right click "jp@gc - Ultimate Thread Group" > Add > Config Element > HTTP Request Defaults.
- Server name or IP: wechat-dev2.vod309.com
- Port Number: 443
- Protocol: https(or http)
- Content encoding: utf-8
- Right click "jp@gc - Ultimate Thread Group" > Add > Listener > View Result Tree.
- Right click "jp@gc - Ultimate Thread Group" > Add > Listener > Aggregate Report.
- Right click "jp@gc - Ultimate Thread Group" > Add > Listener > jp@gc - PerfMon Metrics Collector.
- Right click "jp@gc - Ultimate Thread Group" > Add > Sampler > HTTP request. Make sure requests is after the HTTP Header Manager,HTTP Request Defaults.
- Input full URL in browser and load the page, right click blank area to select "Inspect > NetWork > check Preserve log > XHR > select the request > Headers", collect information from the inspector.
-
GET
- Method: GET
- Path: (your path such as '/wechat-crmapp-perf/api/account/professional/list')
- Parameters: (Headers > General > Request URL), check "Encode?"
-
POSTMethod: POST
- Path: (your path such as '/wechat-crmapp-perf/api/account/professional/list')
- Body Data: (Headers > General > Form Data > view source), copy and paste.
- (Optional, this is for form post)New a HTTP Header Manager under post request, set Name:Content-Type and Value:application/x-www-form-urlencoded; charset=UTF-8.
- Click jp@gc - Ultimate Thread Group to set group parameters
- Start Threads Count : total number of threads you want to run
- Initial Dely,sec :
- Startup time : time to start a thread
- Hold Load For,sec : total run time of script
- Shutdown Time : time to shutdown a thread
- Login server, change directory to PerfMonServerAgent, execute sudo sh ./startAgent.sh --udp-port 0 --tcp-port 39800 to start serverAgent.
- Click Run on the top menu or green play button to run your test plan.
- Click View Result Tree > select a request > Response data, compare it with NetWork > XHR > Response to check if request is really responsed successfully.
- Click Aggregate Report to monitor average, min, max and other statistics of thread group.
- Click jp@gc - PerfMon Metrics Collector to monitor your server behaviour.
网友评论