34
Find the Bottleneck of Your System Load / Stress Test with JMeter StarNight

Find the bottleneck of your system

Embed Size (px)

Citation preview

Page 1: Find the bottleneck of your system

Find the Bottleneckof Your System

Load / Stress Test with JMeter

StarNight

Page 2: Find the bottleneck of your system

Who am I?

潘建宏 / Jian-Hong Pan (StarNight)About Me : http://about.me/StarNight

出沒在~

GitHub : starnightPTT : zack2004plurk : StarNightFacebook : StarNight

目前繼續在種花店當個打雜園丁 ~

Page 3: Find the bottleneck of your system

Outline

● The Bottleneck● Web / HTTP(S)

○ Request / Response Header and Body

● Load / Stress Test● Apache JMeter

○ Installation○ UI Description○ Test Plan○ Read Result○ Parsing and Variables

Page 4: Find the bottleneck of your system

The Bottleneck

● The operation of a system is the cooperation between many parts.

○ Nodes(Termial, Server):Clients, Server, DB○ Connections(Communication)

● The whole system will reach the planned efficiency, only if each part meets the planned efficiency criteria.

DBServer

(Web AP)Clients

PossibleBottleneck

Possible BottleneckPossible Bottleneck

Possible Bottleneck Possible Bottleneck

Page 5: Find the bottleneck of your system

Web / HTTP(S)

● It is the protocol between Client and Web Servers

○ W3C: HTTP Specifications and Drafts○ IETF: RFC 2616 Hypertext Transfer Protocol / 1.1

■ 4.2 Message Headers, 4.3 Message Body■ 5.1.1 Method■ 6.1.1 Status Code and Reason Phrase

● HTTPS: Use SSL certificate to encrypt HTTP

Server(Web AP)Clients

HTTP(S) Request

HTTP(S) Response

Page 6: Find the bottleneck of your system

HTTP Request Header & Body we can see

Secured HTTP Request Header & Body

Page 7: Find the bottleneck of your system

Even though the HTTP is encrypted, you still see the plain text in the browser

Page 8: Find the bottleneck of your system

● Composite of○ Request-Line

■ Method sp Request-URI sp HTTP-Version○ general-header | request-header | entity-header○ message-body

● Method○ OPTIONS, GET, HEAD, POST, PUT, DELETE,

TRACE, CONNECT

● Request-URI○ "*" | absoluteURI | abs_path | authority

● Content-Type

HTTP Request (5)

Page 9: Find the bottleneck of your system

HTTP Response (6)

● Composite of○ Status-Line

■ HTTP-Version sp Status-Code sp Reason-Phrase○ general-header | response-header | entity-header○ message-body

● Status Code and Reason Phrase○ 1xx: Informational○ 2xx: Success○ 3xx: Redirection○ 4xx: Client Error○ 5xx: Server Error

Page 10: Find the bottleneck of your system

Load / Stress Test

● Load Test○ Load testing examines the entire environment and

database, while measuring the response time.

● Stress Test○ Stress testing focuses on identified transactions,

pushing to a level so as to break transactions or systems.

DBServer

(Web AP)Clients

Super Node

HTTP(S) Request

HTTP(S) Response

probe probeprobe

Flow Generator

Page 11: Find the bottleneck of your system

Apache JMeter

● Java application designed to load test functional behavior and measure performance.It was originally designed for testing Web Applications but has since expanded to other test functions.

● http://jmeter.apache.org/● Apache License Version 2.0● Getting Started (User’s Manual)

Open Source is Awesome!

Page 12: Find the bottleneck of your system

Installation

● Download Page:○ http://jmeter.apache.org/download_jmeter.cgi

● Requires Java 6 or later

● Excute bin/jmeter.sh or bin/jmeter.bat

● Using JMeter behind a proxy○ Append the arguments “--proxyHost ProxyServer --

proxyPort ProxyPort” after the ApacheJMeter.jar command in bin/jmeter.sh or bin/jmeter.bat

Page 13: Find the bottleneck of your system

UI DescriptionTest Plan related: Thread, Query Script, Header ...

Workbench to make Test Plan

How to run the Test Plan

Global User Defined Variables

Start / Stop Test Clear Test Result

Page 15: Find the bottleneck of your system

Test Plan - Test Script Recorder

Browser

JMeter Proxy

Target

Client

X

There are only HTTP requests and Responsein the World Wide Web.

Page 16: Find the bottleneck of your system

Open a browser which will go through this proxy

Page 19: Find the bottleneck of your system

Test Plan - HTTP Request Defaults

Variables Default Values

Page 24: Find the bottleneck of your system

Run the Test Plan

Page 25: Find the bottleneck of your system

Read Result - View Results Tree

Page 26: Find the bottleneck of your system

Read Result - Summary Report

Page 27: Find the bottleneck of your system

Parsing

Page 29: Find the bottleneck of your system

Place Variables

${URL_g1}

${URL_g2}

Page 30: Find the bottleneck of your system

Verify Variables

Page 32: Find the bottleneck of your system

Use JMeter Ant addon

1. Download Apache Ant and install it2. Add Ant’s directory into PATH3. Use the command line:

a. cd Apache JMeters’s extras directoryb. ant -Dtest=Test Plan’s File Name -Dtestpath=Path of

the Test Plan’s File

For example: I put the test.jmx on my desktop$ cd C:\Users\jhpan\Desktop\apache-jmeter-2.13\extras$ ant -Dtest=test -Dtestpath=C:\Users\jhpan\Desktop

Page 33: Find the bottleneck of your system
Page 34: Find the bottleneck of your system

Thank you ~