Replaying Web Traffic

Patrick Killelea

Capture Traffic Via A Proxy

Using Sprocket To Record

Output Format

Example Transcript

2853 >>>>>>>> 1199832944.7535
GET http://patrick.net/ HTTP/1.1^M
Accept-Encoding: gzip, deflate^M
Host: patrick.net^M
User-Agent: Mozilla/5.0 (Macintosh; U; en-US; rv:1.8.1.10) Gecko/20071115 Firefox/2.0.0.10^M
Accept: text/xml,application/xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5^M
Accept-Language: en-us^M
---------------: ------------^M
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7^M
Keep-Alive: 300^M
Proxy-Connection: keep-alive^M
^M

2853 <<<<<<<< 1199832945.1593
HTTP/1.1 301 Moved Permanently^M
Transfer-Encoding: chunked^M
Date: Tue, 08 Jan 2008 22:55:38 GMT^M
Server: Apache/2.0.54 (Unix) mod_ssl/2.0.54 OpenSSL/0.9.7l PHP/4.4.0 mod_gzip/2.0.26.1a^M
X-Powered-By: PHP/4.4.0^M
Location: http://patrick.net/housing/crash.html^M
--------------: ---^M
Content-Type: text/html^M
^M
6F^M

Please use http://patrick.net/housing/crash.html
instead
^M
0^M
^M

Options

Sort HTTP

It's possible that responses will come back in a different order than requests were made.

To prevent confusion, we need to sort so that each response comes immediately after its request.

% sort_http out.http > sorted.http

Replay

Trim

Replay Output

% replay trimmed.http
yyyy mm dd hh mm ss.sss latency bytes url
2008 01 08 15 08 20.876 0.227     486 http://patrick.net/

Replay Options

Load Testing

#!/bin/bash -x

((user = 0))
while ((user < 10))
do
    replay trimmed.http > out$user.txt &
    ((user = user + 1))
    perl -pi -e "s/user=user\d+/user=user$user/" trimmed.http
done

Load Testing Example

Load test of real web-based chat site. Site could not be tested with conventional tools, but was testable with sprocket.

Monitoring

Cron Example

# MIN   HOUR   DOM    MOY    DOW   Commands
#(0-59) (0-23) (1-31) (1-12) (0-6) (Note: 0=Sun)
*/10    *      *      *      *     replay home.http > home.out
*/10    *      *      *      *     gnuplot home.gp

Gnuplot Configuration File

set term png
set xdata time
set timefmt "%Y %m %d %H %M"
set ylabel "seconds"
set title "homepage latency"
set output "home.png"
plot 'home.out' using 1:7 notitle with lines

Example Monitor

Anything can be monitored this way, including Bay Area housing prices.

Pros and Cons

Commercial Tools Sprocket
easy ramp up needs command line knowledge
reporting included reporting done manually
expensive free
rigid, limited flexible
proprietary test language   perl
proprietary data format text
obscure clear what is going on

Download

sprocket

sort_http

trim

replay