Performance Testing of Web Applications
Performance Testing of Web Applications
for
Web Applications
March 2018
1
Web Application Performance Testing
Performance Test Process
Scripting
2
Performance Test Process
Discovery and Planning
Preparation
Execution
Reporting
3
Discovery and Planning
Agree on:
Requirements
Test scripts
Transaction volumes
Test scenarios
Test data
4
Discovery and Planning
Agree on:
Execution environment
Test schedule
5
Discovery and Planning
Use the information to produce a Performance Test Plan
6
Preparation
Create test scripts
7
Execution
Run tests according to the schedule
8
Execution – Performance Tuning
Scientific process
9
Reporting
Write the report assuming that recipients will only read the executive
summary
The rest of the report is evidence to justify what is written in the executive
summary
10
Reporting
What did the test do: number or users, transactions per second
What might be the cause of any problems: ran out of a resource, used too
much of a resource
11
HTTP Protocol
Request / Response protocol
There is no way for a server to initiate a message – but there are several
ways to simulate it
12
URL Structure
protocol://server:port/path/file.ext?parameter=value¶meter2=value2
https://www.austrade.gov.au/search.aspx?ModuleID=8367&keywords=livestock
%20export&multiSite=False
13
URL Structure - Protocol
HTTP – no encryption
or
14
URL Structure - Port
15
Request Methods - Get
16
Request Methods - Post
17
Request Methods – Unicorns
18
HTTP Status Codes
1xx – Informational
2xx – Successful
3xx – Redirection
19
Encoding
Problem: The web server needs to be able to determine the difference between
20
HTML Encoding
Examples:
> >
< <
& &
21
URL Encoding
Escape Character: %
Examples:
space + or %20
% %25
= %3D
22
C / Java / Javascript String Encoding
Escape Character: \
Examples:
“ \”
\ \\
CR \r
23
Base 64 Encoding
Example:
ABCD1234 QUJDRDEyMzQ=
24
multipart/form-data
25
multipart/form-data
Example:
Content-Type: multipart/form-data; boundary=H0kKzlo9
--H0kKzlo9
Content-Disposition: form data; name=“Username”
U217913
--H0kKzlo9
Content-Disposition: form data; name=“Password”
ABCD1234
--H0kKzlo9--
26
Cookies
A text string sent by a web server and stored by the browser
The browser sends it back in the header for every subsequent request to that
server
27
Cookies
Session cookies exist only during a browser session
28
Caching – Cache-Control
Web servers send a Cache-Control header to tell the client and intermediate
proxies how to cache the resource
29
Caching – Cache-Control
Cache-Control:public
Any proxies can cache the resource
Cache-Control:private
Proxies should not cache the resource
Cache-Control:no-cache
Always check with the server to see if there is a newer version
Cache-Control:no-store
Do not cache the resource
30
Caching – Expires
Web servers send an Expires header with the timestamp when the resource
is no longer valid
If the timestamp hasn’t expired then the browser will use the copy stored in
the cache and no communication will occur with the web server
If the timestamp has expired then the resource will be requested from the
server again
31
Caching – max-age
Web servers send a max-age field in the Cache-Control header with the
amount of time in seconds before the resource is no longer valid
If the maximum age hasn’t been reached then the browser will use the copy
stored in the cache and no communication will occur with the web server
If the maximum age has been reached then the resource will be requested
from the server again
32
Caching – Last Modified
Web servers send a Last Modified header with the timestamp when the
resource was last modified
The browser sends the timestamp back in the If-Modified-Since header for
every subsequent request for that resource
If the resource hasn’t changed then the server responds with 304 Not
Modified and the browser will use the copy stored in the cache
If the resource has changed then a new version of the resource will be
returned with a new Last Modified header
33
Caching – ETag
Web servers send an ETag header with a MD5 hash of the resource
The browser sends the ETag back in the If-None-Match header for every
subsequent request for that resource
If the resource hasn’t changed then the server responds with 304 Not
Modified and the browser will use the copy stored in the cache
If the resource has changed a new version of the resource will be returned
with a new ETag header
34
Redirects
Server responds with a 301, 303 or 307 HTTP response code
The Location header in the response has the location of the new page
The browser automatically sends a Get for the page in the location header
35
AJAX
Allows the page to be modified without requesting the whole page again
Javascript requests data from the web server without getting a new page
JSON is becoming more common than XML but the process works the same
36
(Psuedo-)Push Messages
Client polling
Long poll
Long response
37
(Psuedo-)Push Messages – Client Polling
Client polls for updates based on a timer
Can cause excessive load on the server as the client may request updates
when no changes have occurred
38
(Psuedo-)Push Messages – Long Poll
Client sends a request
39
(Psuedo-)Push Messages – Large Response
Client requests an update
40
Script Types
Protocol Scripts
GUI Scripts
41
Protocol Scripts
Emulate usage of the application by sending HTTP requests
Have a low overhead on load generators so many can run on one server
42
GUI Scripts
Emulate usage of the application by interacting with the browser
Have a very high overhead on load generators so only few can run on one
server
Can be faster to create than Protocol scripts but in many cases can be slower
Can be less reliable than Protocol scripts and may require much more error
handling.
43
Protocol Scripts vs GUI Scripts
Only use GUI scripts when:
44
Script Recording
Web Browser Hooking
Browser Add-in
Proxy
HAR file
45
Script Recording
Only requests are recorded
46
Correlation
Usually a script that is recorded will not play back without changes
47
Correlation
These changes are dealt with by capturing the response from the server and
using it to modify subsequent requests
This where you typically spend most of your time when creating protocol
scripts
48
Correlation
Determine the field that you wish to correlate
49
Correlation
What if I can’t find the field in a previous response?
Use a Javascript debugger to trace through the Javascript to see where the
field is getting created
50
Correlation
Boundaries
Regular Expression
Xpath
51
Validation
Most tools will automatically error based on HTTP 4xx and 5xx responses
52
53