Web Performance
Culture and Tools
at Etsy
         Mike Brittain
         @mikebrittain

         Director of Eng., Infrastructure
         Etsy
All of this started in the last year.
Make Performance
Matter
$0.20 per item
3.5% transaction fee
Focus on the marketplace
ecommerce
ecommerce
ad supported
ecommerce
ad supported
subscription
ecommerce
ad supported
subscription
“free”
$$$
“Prove it.”
“Our own years of testing
have conclusively shown that
 when speed of a feature or
  product improves, usage,
   quite simply, goes up.”

         http://googleblog.blogspot.com/2009/12/this-week-in-search-121809.html
100+ web, api, jobs
40+ databases
Many more doing lots of other stuff...
$$$
Performance is fun
I want you to tell me
   how you feel...
95th percentile
milliseconds




                 Average
e
                                            w r!
                                          en ste
                                         h a
               95th percentile          w f
                                      is go
                                   is it
                                  h e
                                 T d
milliseconds




                                  m a


                 Average
I am better than you.
Make Performance
Matter
Performance
Culture
Our perf team is two people...
Measure
Measure
Build tools
Measure
Build tools
Train & Coordinate
Measure
Build tools
Train & Coordinate
Motivate
Measure
Build tools
Train & Coordinate
Motivate
Dedicated
Our perf team is two people...
  But every engineer thinks
     about performance
Everything is slow.
Please fix.
page generation
time
2011 Goal
800 ms on five pages
http://www.etsy.com/blog/news/2011/november-2011-site-performance-report/
http://www.etsy.com/blog/news/2011/november-2011-site-performance-report/
Performance degradation
is a P2 bug
WARNING: This part is hard


Performance degradation
is a P2 bug
2012 Goal
800 ms for all pages
Engineering
Denormalize data
Optimize queries
Rewrite from scratch
Caching (memcache, app code)
Operations
Network switches
Operating systems
Newer hardware
Additional hardware capacity
Product
Identify concerns early
Kill lagging features
Performance
Culture
Tools
How do you make
the graphs?
Perf-related data belongs in
      your server logs
apache_note(“custom_field”, $whatever);
LogFormat %l %t "%r" %>s %b "%{Referer}i"
"%{User-Agent}i" %{custom_field}n
LogFormat "%{True-Client-IP}i %l %u %t "%r"
%>s %b "%{Referer}i" "%{User-Agent}i"
%{etsy_user_id}n %{php_bytes}n %{php_microsec}n
%D" combined
$timer_start = microtime(true);
 ...
$timer_diff = microtime(true) - $timer_start;


register_shutdown_function()

apache_note('php_microsec', $timer_diff);
web0060 66.249.71.110 - - [24/Aug/2011:04:16:52
+0000] "GET /listing/12189259/tropical-etched-
pair-of-lampwork-glass HTTP/1.1" 200 11034 "-"
"Mozilla/5.0 (compatible; Googlebot/2.1;
+http://www.google.com/bot.html)"
- 13399576 505780 554876
Using something else?
time, http method, request uri, response code, referer,
user-agent, response time, response memory,
custom segmentation fields...
Quick averages
grep "GET /listing/" access.log | 

awk '{sum=sum+$(NF-1)} END {print sum/NR}'
Quick graphs
grep "GET /listing/" access.log | 

perl -pe "s/.*[.*d{4}:(d{2}):(d{2}):d{2}.*]/1:2/" | 

awk '{print $1, $(NF-1)}' > /tmp/pagetimes.dat




                                                 gives you...
Quick graphs
# /tmp/pagetimes.dat

18:37   251.0
18:38   252.1
18:39   253.5
18:40   251.0
18:45   250.0          and then...
Quick graphs
# GNUPLOT

set terminal png
set output 'listings.png'
set yrange [0:2000]
set xdata time
set timefmt "%d/%B/%Y:%H:%M:%S"
set format x "%H:%M"
plot '/tmp/pagetimes.dat' using 1:2 with points
Quick graphs
Logster
Run by cron
Maintains a cursor on log files
Simple parsing & aggregation
Output to Ganglia or Graphite



                                 github.com/etsy
Logster & Graphite


         Signed-in vs. Signed-out
Response times
responses (pages)




                         by bucket



                    time (ms)
“Look at your Data”
John Rauser, Velocity 2011


   http://www.youtube.com/watch?v=coNDCIMH8bk
Idea lifted from
http://www.codinghorror.com/blog/2011/06/
performance-is-a-feature.html
Don’t forget the API
Measure
performance
data in Production
Profiling
“I/O Profiler”
Lightweight, inline profiling
Start and end times wrapped around service calls
   databases, memcache, apc, 3rd party services, etc.
Enable with query string
“I/O Profiler”
“I/O Profiler”
XHProf
github.com/facebook/xhprof


Deployed on pre-prod machine
Direct access to profiling
Enable with query string
Profile against
Production
Make performance matter
Start small
Make graphs and reports
Create simple tools
Celebrate performance wins
Thank you
           codeascraft.etsy.com
Mike Brittain
mike@etsy.com
@mikebrittain
Jobs at Etsy
 We are currently hiring for a number of
 positions in engineering and operations.

 http://www.etsy.com/careers

Web Performance Culture and Tools at Etsy