SlideShare a Scribd company logo
1 of 37
Download to read offline
LOAD TESTING
      WITH PYTHON

dan kuebrich / dan.kuebrich@gmail.com / @dankosaur
                                                     1
$finger dkuebric
• Currently: Tracelytics

• Before: Songza.com /
  AmieStreet.com


• Likes websites, soccer, and beer


                                     2
MENU
• What is load testing?
• How does it work?
• One good way to do it
  • (with Python, no less!)
• A few examples
• Survey: making sense of it all


                                   3
WHAT IS LOAD TESTING
• AKA stress testing
• Putting demand on a system (web app)
 and measuring its response (latency,
 availability)




           http://www.flickr.com/photos/60258236@N02/5515327431/



                                                                  4
Q: WILL IT PERFORM
Do my code + infrastructure provide the
desired level of performance in terms of
  latency and throughput for real user
               workloads?

    And if not, how can I get there?




                                           5
http://www.flickr.com/photos/dvs/3540320095/


                                              6
WHEN TO LOAD TEST

• Launching a new feature (or site!)
• Expect a big traffic event
• Changing infrastructure
• “I just don’t like surprises”


                                       7
A PAGEVIEW IS BORN
        now DNS
          give can
             I me
         lolcats
       search results
            First HTTP request

           Retrieve assets
           and run js




t=0                              t=done
                                          8
THE WATERFALL CHART




                      9
A PAGEVIEW IS BORN
           yslow?




DNS, connection
     Fulfill HTTP Request (“Time to first byte”)
                    Download + render page contents
                                   (+js)

                                                      10
HOW TO TEST IT

most common    • “F*ck it, we’ll do it live!”
               • Synthetic HTTP requests
                (“Virtual Users / VUs”)

least common
               • Synthetic clicks in real
                browsers (“RBUs”)



                                                11
VU vs RBU
              VU                            RBU
• Simulate individual           • Operate a browser
protocol-level requests


• Low overhead                  • Higher overhead

• Scripts must parallel user    • Scripts must parallel user
behavior                        behavior


• Tough to get AJAX-heavy       • Accurate simulation of
sites exactly right, maintain   AJAX

                                                               12
MULTI-MECHANIZE
• FOSS (LGPL v3), based on mechanize
• Load generation framework for VUs
• Written in Python, scripted in Python
• Heavyweight for bandwidth-bound
 tests, but stocked with py-goodness


                                          13
MULTI-MECHANIZE
• Basic idea:
 • Write a few scripts that simulate
    user actions or paths

 • Specify how you want to run them:
    x VUs in parallel on script A, y on
    script B, ramping up, etc.

 • Run and watch
                                          14
A SIMPLE M-M SCRIPT
get_index.py
import	
  requests

class	
  Transaction(object):
	
  	
  def	
  run(self):
	
  	
  	
  	
  r	
  =	
  requests.get(‘http://website.com/’)
	
  	
  	
  	
  r.raw.read()




                                                                15
A SIMPLE PROJECT
• A multi-mechanize “project” is a set of
  test scripts and a config that specifies
  how to run them:
dan@host:~/mm/my_project$	
  ls	
  -­‐1	
  
.
..
config.cfg	
  	
  	
  	
  	
  	
  	
  	
  #	
  config	
  file
test_scripts/	
  	
  	
  	
  	
  #	
  your	
  tests	
  are	
  here
results/	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  #	
  result	
  files	
  go	
  here




                                                                                     16
A SIMPLE PROJECT
config.cfg
[global]
run_time:	
  60
rampup:	
  60
results_ts_interval:	
  60
console_logging:	
  off
progress_bar:	
  on

[user_group-­‐1]
threads:	
  25
script:	
  get_index.py




                             17
A FEW M-M FEATURES
features.py
import	
  requests
import	
  time

class	
  Transaction(object):
	
  	
  def	
  run(self):
	
  	
  	
  	
  r	
  =	
  requests.get(‘http://website.com/a’)
	
  	
  	
  	
  r.raw.read()
	
  	
  	
  	
  assert	
  (r.status_code	
  ==	
  200),	
  ‘not	
  200’
	
  	
  	
  	
  assert	
  (‘Error’	
  not	
  in	
  r.text)

	
  	
  	
  	
  t1	
  =	
  time.time()
	
  	
  	
  	
  r	
  =	
  requests.get(‘http://website.com/b’)
	
  	
  	
  	
  r.raw.read()
	
  	
  	
  	
  latency	
  =	
  time.time()	
  -­‐	
  t1
	
  	
  	
  	
  self.custom_timers[‘b’]	
  =	
  latency
                                                                          18
[	
  $	
  multimech-­‐run	
  example	
  ]




                                            19
INTERACTION
login.py
import	
  mechanize	
  as	
  m

class	
  MyTransaction(object):
	
  	
  def	
  run(self):
	
  	
  	
  	
  br	
  =	
  m.Browser()
	
  	
  	
  	
  br.set_handle_equiv(True)
	
  	
  	
  	
  br.set_handle_gzip(True)
	
  	
  	
  	
  br.set_handle_redirect(True)
	
  	
  	
  	
  br.set_handle_referer(True)
	
  	
  	
  	
  br.set_handle_robots(False)
	
  	
  	
  	
  br.set_handle_refresh(m._http.HTTPRefreshProcessor(),	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  max_time=1)
	
  	
  	
  	
  _	
  =	
  br.open(‘http://reddit.tlys.us’)

	
  	
  	
  	
  br.select_form(nr=1)
	
  	
  	
  	
  br.form['user']	
  =	
  u
	
  	
  	
  	
  br.form['passwd']	
  =	
  p
	
  	
  	
  	
  r	
  =	
  br.submit()
	
  	
  	
  	
  r.read()

                                                                                                                      20
[	
  $	
  cat	
  more-­‐advanced-­‐example.py	
  ]
[	
  $	
  multimech-­‐run	
  more-­‐advanced	
  	
  ]




                                                        21
GETTING INSIGHT
• First, is the machine working hard?
 • Inspect basic resources: CPU/RAM/
    IO

 • Ganglia/Munin/etc.



                                        22
MUNIN




        23
GETTING INSIGHT
• Second, why is the machine working
  hard?

 • What is my app doing?
 • What are my databases doing?
 • How are my caches performing?

                                       24
REDDIT: A PYLONS APP

                   nginx

memcached         uwsgi
                  pylons


   postgresql                 cassandra

                queued jobs


                                          25
REDDIT: A PYLONS APP
                                          request start

                   nginx

memcached         uwsgi
                  pylons


   postgresql                 cassandra

                queued jobs               request end

                                                          26
REDDIT: A PYLONS APP
                                          request start

                   nginx

memcached         uwsgi
                  pylons


   postgresql                 cassandra

                queued jobs               request end

                                                          27
INSIDE THE APP
              PROFILING      VS          INSTRUMENTATION

• Fine-grained analysis of        • Gather curated set of
Python code                       information
• Easy to set up                  • Requires monkey-patching
                                  (or code edits)
• No visibility into DB,          • Can connect DB, cache
cache, etc.                       performance to app
• Distorts app performance        • Little (tunable) overhead
• profile, cProfile                 • django-debug-toolbar,
                                  statsd, Tracelytics, New Relic


                                                                   28
PROFILING 101
• ncalls: # of calls to method              • cumtime: time spent in that
                                            method and all child calls
• tottime: total time spent
exclusively in that method                  • Try repoze.profile for WSGI
   ncalls      tottime   percall cumtime   percall filename:lineno(function)
   892048      12.643     0.000  17.676     0.000 thing.py:116(__getattr__)
14059/2526      9.475     0.001  34.159     0.014 template_helpers.py:181(_replace_render)
   562060       7.384     0.000   7.384     0.000 {posix.stat}
204587/163113   6.908     0.000  51.302     0.000 filters.py:111(mako_websafe)
115192/109693   6.590     0.000   9.700     0.000 {method 'join' of 'str' objects}
  1537933       6.584     0.000  15.437     0.000 registry.py:136(__getattr__)
1679803/1404938 5.294     0.000  11.767     0.000 {hasattr}
2579769/2434607 5.173     0.000  12.713     0.000 {getattr}
      139       4.809     0.035 106.065     0.763 pages.py:1004(__init__)
     8146       3.967     0.000  15.031     0.002 traceback.py:280(extract_stack)
    43487       3.942     0.000   3.942     0.000 {method 'recv' of '_socket.socket' object
   891579       3.759     0.000  21.430     0.000 thing.py:625(__getattr__)
    72021       3.633     0.000   5.910     0.000 memcache.py:163(serverHashFunction)
      201       3.319     0.017  38.667     0.192 pages.py:336(render)
      392       3.236     0.008   3.236     0.008 {Cfilters.uspace_compress}
  1610797       3.208     0.000   3.209     0.000 registry.py:177(_current_obj)
  2017343       3.113     0.000   3.211     0.000 {isinstance}

                                                                                        29
INSTRUMENTATION
• DB queries
• Cache usage
• RPC calls
• Optionally profile critical segments of
code
• Exceptions
• Associate with particular codepaths or
URLs


                                           30
DJANGO-DEBUG-TOOLBAR




                       31
STATSD/GRAPHITE




                  32
TRACELYTICS/NEW RELIC




                        33
THANKS!
            (any questions?)

• Multi-mechanize: testutils.org/multi-
 mechanize/

• Email me: dan.kuebrich@gmail.com
• My job: tracelytics.com



                                          34
APPENDIX
• Multi-mechanize
   • Download: testutils.org/multi-mechanize
   • Development: github.com/cgoldberg/multi-mechanize
   • Mechanize: wwwsearch.sourceforge.net/mechanize/
• Reddit
   • Source: github.com/reddit/reddit
   • Demo load test: github.com/dankosaur/reddit-loadtest
• RBU load testing
   • BrowserMob: browsermob.com/performance-testing
   • LoadStorm: loadstorm.com
   • New, but promising: github.com/detro/ghostdriver



                                                            35
APPENDIX
• Machine monitoring:
   • Ganglia: ganglia.sourceforge.net
   • Munin: munin-monitoring.org
• Application monitoring:
   • repoze.profile: docs.repoze.org/profile/
   • Django-Debug-Toolbar: github.com/django-debug-
    toolbar/django-debug-toolbar
  • Graphite: graphite.wikidot.com
     • and statsd: github.com/etsy/statsd
     • and django instrumentation: pypi.python.org/pypi/
       django-statsd/1.8.0
  • Tracelytics: tracelytics.com


                                                           36
AND:   TRACELYTICS FREE TRIAL

         We’ve got a 14-day trial; with only
       minutes to install, you’ll have plenty of
       time for load testing. No credit card
                     required!


                       http://tracelytics.com



                                                   37

More Related Content

What's hot

Владимир Перепелица "Модули"
Владимир Перепелица "Модули"Владимир Перепелица "Модули"
Владимир Перепелица "Модули"Media Gorod
 
Nodejs Explained with Examples
Nodejs Explained with ExamplesNodejs Explained with Examples
Nodejs Explained with ExamplesGabriele Lana
 
We Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End DevelopmentWe Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End DevelopmentAll Things Open
 
PyCon AU 2015 - Using benchmarks to understand how wsgi servers work
PyCon AU 2015  - Using benchmarks to understand how wsgi servers workPyCon AU 2015  - Using benchmarks to understand how wsgi servers work
PyCon AU 2015 - Using benchmarks to understand how wsgi servers workGraham Dumpleton
 
Performance Optimization of Rails Applications
Performance Optimization of Rails ApplicationsPerformance Optimization of Rails Applications
Performance Optimization of Rails ApplicationsSerge Smetana
 
"Swoole: double troubles in c", Alexandr Vronskiy
"Swoole: double troubles in c", Alexandr Vronskiy"Swoole: double troubles in c", Alexandr Vronskiy
"Swoole: double troubles in c", Alexandr VronskiyFwdays
 
Implement server push in flask framework
Implement server push in flask frameworkImplement server push in flask framework
Implement server push in flask frameworkChi-Chia Huang
 
Basic testing with selenium
Basic testing with seleniumBasic testing with selenium
Basic testing with seleniumSøren Lund
 
Rails Application Optimization Techniques & Tools
Rails Application Optimization Techniques & ToolsRails Application Optimization Techniques & Tools
Rails Application Optimization Techniques & Toolsguest05c09d
 
Load Testing with PHP and RedLine13
Load Testing with PHP and RedLine13Load Testing with PHP and RedLine13
Load Testing with PHP and RedLine13Jason Lotito
 
Load Testing with RedLine13: Or getting paid to DoS your own systems
Load Testing with RedLine13: Or getting paid to DoS your own systemsLoad Testing with RedLine13: Or getting paid to DoS your own systems
Load Testing with RedLine13: Or getting paid to DoS your own systemsJason Lotito
 
Recent Updates at Embulk Meetup #3
Recent Updates at Embulk Meetup #3Recent Updates at Embulk Meetup #3
Recent Updates at Embulk Meetup #3Muga Nishizawa
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.jsjacekbecela
 
Our Puppet Story (Linuxtag 2014)
Our Puppet Story (Linuxtag 2014)Our Puppet Story (Linuxtag 2014)
Our Puppet Story (Linuxtag 2014)DECK36
 
Embulk - 進化するバルクデータローダ
Embulk - 進化するバルクデータローダEmbulk - 進化するバルクデータローダ
Embulk - 進化するバルクデータローダSadayuki Furuhashi
 
Using Node.js to Build Great Streaming Services - HTML5 Dev Conf
Using Node.js to  Build Great  Streaming Services - HTML5 Dev ConfUsing Node.js to  Build Great  Streaming Services - HTML5 Dev Conf
Using Node.js to Build Great Streaming Services - HTML5 Dev ConfTom Croucher
 
Using Embulk at Treasure Data
Using Embulk at Treasure DataUsing Embulk at Treasure Data
Using Embulk at Treasure DataMuga Nishizawa
 
Node js presentation
Node js presentationNode js presentation
Node js presentationmartincabrera
 

What's hot (20)

Владимир Перепелица "Модули"
Владимир Перепелица "Модули"Владимир Перепелица "Модули"
Владимир Перепелица "Модули"
 
Nodejs Explained with Examples
Nodejs Explained with ExamplesNodejs Explained with Examples
Nodejs Explained with Examples
 
We Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End DevelopmentWe Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End Development
 
PyCon AU 2015 - Using benchmarks to understand how wsgi servers work
PyCon AU 2015  - Using benchmarks to understand how wsgi servers workPyCon AU 2015  - Using benchmarks to understand how wsgi servers work
PyCon AU 2015 - Using benchmarks to understand how wsgi servers work
 
Performance Optimization of Rails Applications
Performance Optimization of Rails ApplicationsPerformance Optimization of Rails Applications
Performance Optimization of Rails Applications
 
"Swoole: double troubles in c", Alexandr Vronskiy
"Swoole: double troubles in c", Alexandr Vronskiy"Swoole: double troubles in c", Alexandr Vronskiy
"Swoole: double troubles in c", Alexandr Vronskiy
 
Implement server push in flask framework
Implement server push in flask frameworkImplement server push in flask framework
Implement server push in flask framework
 
Basic testing with selenium
Basic testing with seleniumBasic testing with selenium
Basic testing with selenium
 
Rails Application Optimization Techniques & Tools
Rails Application Optimization Techniques & ToolsRails Application Optimization Techniques & Tools
Rails Application Optimization Techniques & Tools
 
Load Testing with PHP and RedLine13
Load Testing with PHP and RedLine13Load Testing with PHP and RedLine13
Load Testing with PHP and RedLine13
 
Load Testing with RedLine13: Or getting paid to DoS your own systems
Load Testing with RedLine13: Or getting paid to DoS your own systemsLoad Testing with RedLine13: Or getting paid to DoS your own systems
Load Testing with RedLine13: Or getting paid to DoS your own systems
 
Everything as a code
Everything as a codeEverything as a code
Everything as a code
 
Recent Updates at Embulk Meetup #3
Recent Updates at Embulk Meetup #3Recent Updates at Embulk Meetup #3
Recent Updates at Embulk Meetup #3
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
 
Celery with python
Celery with pythonCelery with python
Celery with python
 
Our Puppet Story (Linuxtag 2014)
Our Puppet Story (Linuxtag 2014)Our Puppet Story (Linuxtag 2014)
Our Puppet Story (Linuxtag 2014)
 
Embulk - 進化するバルクデータローダ
Embulk - 進化するバルクデータローダEmbulk - 進化するバルクデータローダ
Embulk - 進化するバルクデータローダ
 
Using Node.js to Build Great Streaming Services - HTML5 Dev Conf
Using Node.js to  Build Great  Streaming Services - HTML5 Dev ConfUsing Node.js to  Build Great  Streaming Services - HTML5 Dev Conf
Using Node.js to Build Great Streaming Services - HTML5 Dev Conf
 
Using Embulk at Treasure Data
Using Embulk at Treasure DataUsing Embulk at Treasure Data
Using Embulk at Treasure Data
 
Node js presentation
Node js presentationNode js presentation
Node js presentation
 

Similar to Python Load Testing - Pygotham 2012

Kubernetes Navigation Stories – DevOpsStage 2019, Kyiv
Kubernetes Navigation Stories – DevOpsStage 2019, KyivKubernetes Navigation Stories – DevOpsStage 2019, Kyiv
Kubernetes Navigation Stories – DevOpsStage 2019, KyivAleksey Asiutin
 
J1 2015 "Debugging Java Apps in Containers: No Heavy Welding Gear Required"
J1 2015 "Debugging Java Apps in Containers: No Heavy Welding Gear Required"J1 2015 "Debugging Java Apps in Containers: No Heavy Welding Gear Required"
J1 2015 "Debugging Java Apps in Containers: No Heavy Welding Gear Required"Daniel Bryant
 
Sherlock Homepage - A detective story about running large web services - WebN...
Sherlock Homepage - A detective story about running large web services - WebN...Sherlock Homepage - A detective story about running large web services - WebN...
Sherlock Homepage - A detective story about running large web services - WebN...Maarten Balliauw
 
Celery: The Distributed Task Queue
Celery: The Distributed Task QueueCelery: The Distributed Task Queue
Celery: The Distributed Task QueueRichard Leland
 
The power of linux advanced tracer [POUG18]
The power of linux advanced tracer [POUG18]The power of linux advanced tracer [POUG18]
The power of linux advanced tracer [POUG18]Mahmoud Hatem
 
Real World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS ApplicationReal World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS ApplicationBen Hall
 
OpenNebulaConf 2016 - Measuring and tuning VM performance by Boyan Krosnov, S...
OpenNebulaConf 2016 - Measuring and tuning VM performance by Boyan Krosnov, S...OpenNebulaConf 2016 - Measuring and tuning VM performance by Boyan Krosnov, S...
OpenNebulaConf 2016 - Measuring and tuning VM performance by Boyan Krosnov, S...OpenNebula Project
 
K8s best practices from the field!
K8s best practices from the field!K8s best practices from the field!
K8s best practices from the field!DoiT International
 
Serverless on OpenStack with Docker Swarm, Mistral, and StackStorm
Serverless on OpenStack with Docker Swarm, Mistral, and StackStormServerless on OpenStack with Docker Swarm, Mistral, and StackStorm
Serverless on OpenStack with Docker Swarm, Mistral, and StackStormDmitri Zimine
 
Genomic Computation at Scale with Serverless, StackStorm and Docker Swarm
Genomic Computation at Scale with Serverless, StackStorm and Docker SwarmGenomic Computation at Scale with Serverless, StackStorm and Docker Swarm
Genomic Computation at Scale with Serverless, StackStorm and Docker SwarmDmitri Zimine
 
基于Mongodb的压力评测工具 ycsb的一些概括
基于Mongodb的压力评测工具 ycsb的一些概括基于Mongodb的压力评测工具 ycsb的一些概括
基于Mongodb的压力评测工具 ycsb的一些概括Louis liu
 
PyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsPyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsGraham Dumpleton
 
What to expect from Java 9
What to expect from Java 9What to expect from Java 9
What to expect from Java 9Ivan Krylov
 
What's New in Docker - February 2017
What's New in Docker - February 2017What's New in Docker - February 2017
What's New in Docker - February 2017Patrick Chanezon
 
手把手教你如何串接 Log 到各種網路服務
手把手教你如何串接 Log 到各種網路服務手把手教你如何串接 Log 到各種網路服務
手把手教你如何串接 Log 到各種網路服務Mu Chun Wang
 
Django deployment with PaaS
Django deployment with PaaSDjango deployment with PaaS
Django deployment with PaaSAppsembler
 
Kubecon seattle 2018 workshop slides
Kubecon seattle 2018 workshop slidesKubecon seattle 2018 workshop slides
Kubecon seattle 2018 workshop slidesWeaveworks
 
OWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersOWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersJavan Rasokat
 
Monitoring a Kubernetes-backed microservice architecture with Prometheus
Monitoring a Kubernetes-backed microservice architecture with PrometheusMonitoring a Kubernetes-backed microservice architecture with Prometheus
Monitoring a Kubernetes-backed microservice architecture with PrometheusFabian Reinartz
 

Similar to Python Load Testing - Pygotham 2012 (20)

Iac d.damyanov 4.pptx
Iac d.damyanov 4.pptxIac d.damyanov 4.pptx
Iac d.damyanov 4.pptx
 
Kubernetes Navigation Stories – DevOpsStage 2019, Kyiv
Kubernetes Navigation Stories – DevOpsStage 2019, KyivKubernetes Navigation Stories – DevOpsStage 2019, Kyiv
Kubernetes Navigation Stories – DevOpsStage 2019, Kyiv
 
J1 2015 "Debugging Java Apps in Containers: No Heavy Welding Gear Required"
J1 2015 "Debugging Java Apps in Containers: No Heavy Welding Gear Required"J1 2015 "Debugging Java Apps in Containers: No Heavy Welding Gear Required"
J1 2015 "Debugging Java Apps in Containers: No Heavy Welding Gear Required"
 
Sherlock Homepage - A detective story about running large web services - WebN...
Sherlock Homepage - A detective story about running large web services - WebN...Sherlock Homepage - A detective story about running large web services - WebN...
Sherlock Homepage - A detective story about running large web services - WebN...
 
Celery: The Distributed Task Queue
Celery: The Distributed Task QueueCelery: The Distributed Task Queue
Celery: The Distributed Task Queue
 
The power of linux advanced tracer [POUG18]
The power of linux advanced tracer [POUG18]The power of linux advanced tracer [POUG18]
The power of linux advanced tracer [POUG18]
 
Real World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS ApplicationReal World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS Application
 
OpenNebulaConf 2016 - Measuring and tuning VM performance by Boyan Krosnov, S...
OpenNebulaConf 2016 - Measuring and tuning VM performance by Boyan Krosnov, S...OpenNebulaConf 2016 - Measuring and tuning VM performance by Boyan Krosnov, S...
OpenNebulaConf 2016 - Measuring and tuning VM performance by Boyan Krosnov, S...
 
K8s best practices from the field!
K8s best practices from the field!K8s best practices from the field!
K8s best practices from the field!
 
Serverless on OpenStack with Docker Swarm, Mistral, and StackStorm
Serverless on OpenStack with Docker Swarm, Mistral, and StackStormServerless on OpenStack with Docker Swarm, Mistral, and StackStorm
Serverless on OpenStack with Docker Swarm, Mistral, and StackStorm
 
Genomic Computation at Scale with Serverless, StackStorm and Docker Swarm
Genomic Computation at Scale with Serverless, StackStorm and Docker SwarmGenomic Computation at Scale with Serverless, StackStorm and Docker Swarm
Genomic Computation at Scale with Serverless, StackStorm and Docker Swarm
 
基于Mongodb的压力评测工具 ycsb的一些概括
基于Mongodb的压力评测工具 ycsb的一些概括基于Mongodb的压力评测工具 ycsb的一些概括
基于Mongodb的压力评测工具 ycsb的一些概括
 
PyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsPyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web Applications
 
What to expect from Java 9
What to expect from Java 9What to expect from Java 9
What to expect from Java 9
 
What's New in Docker - February 2017
What's New in Docker - February 2017What's New in Docker - February 2017
What's New in Docker - February 2017
 
手把手教你如何串接 Log 到各種網路服務
手把手教你如何串接 Log 到各種網路服務手把手教你如何串接 Log 到各種網路服務
手把手教你如何串接 Log 到各種網路服務
 
Django deployment with PaaS
Django deployment with PaaSDjango deployment with PaaS
Django deployment with PaaS
 
Kubecon seattle 2018 workshop slides
Kubecon seattle 2018 workshop slidesKubecon seattle 2018 workshop slides
Kubecon seattle 2018 workshop slides
 
OWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersOWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA Testers
 
Monitoring a Kubernetes-backed microservice architecture with Prometheus
Monitoring a Kubernetes-backed microservice architecture with PrometheusMonitoring a Kubernetes-backed microservice architecture with Prometheus
Monitoring a Kubernetes-backed microservice architecture with Prometheus
 

Recently uploaded

“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdfMuhammad Subhan
 
UiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewUiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewDianaGray10
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Paige Cruz
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsLeah Henrickson
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTopCSSGallery
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024Lorenzo Miniero
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityVictorSzoltysek
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxjbellis
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxFIDO Alliance
 
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Skynet Technologies
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard37
 
CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)Wonjun Hwang
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceSamy Fodil
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctBrainSell Technologies
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfdanishmna97
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireExakis Nelite
 
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimaginedpanagenda
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxFIDO Alliance
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptxFIDO Alliance
 

Recently uploaded (20)

“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
 
UiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewUiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overview
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development Companies
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptx
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptx
 
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 

Python Load Testing - Pygotham 2012

  • 1. LOAD TESTING WITH PYTHON dan kuebrich / dan.kuebrich@gmail.com / @dankosaur 1
  • 2. $finger dkuebric • Currently: Tracelytics • Before: Songza.com / AmieStreet.com • Likes websites, soccer, and beer 2
  • 3. MENU • What is load testing? • How does it work? • One good way to do it • (with Python, no less!) • A few examples • Survey: making sense of it all 3
  • 4. WHAT IS LOAD TESTING • AKA stress testing • Putting demand on a system (web app) and measuring its response (latency, availability) http://www.flickr.com/photos/60258236@N02/5515327431/ 4
  • 5. Q: WILL IT PERFORM Do my code + infrastructure provide the desired level of performance in terms of latency and throughput for real user workloads? And if not, how can I get there? 5
  • 7. WHEN TO LOAD TEST • Launching a new feature (or site!) • Expect a big traffic event • Changing infrastructure • “I just don’t like surprises” 7
  • 8. A PAGEVIEW IS BORN now DNS give can I me lolcats search results First HTTP request Retrieve assets and run js t=0 t=done 8
  • 10. A PAGEVIEW IS BORN yslow? DNS, connection Fulfill HTTP Request (“Time to first byte”) Download + render page contents (+js) 10
  • 11. HOW TO TEST IT most common • “F*ck it, we’ll do it live!” • Synthetic HTTP requests (“Virtual Users / VUs”) least common • Synthetic clicks in real browsers (“RBUs”) 11
  • 12. VU vs RBU VU RBU • Simulate individual • Operate a browser protocol-level requests • Low overhead • Higher overhead • Scripts must parallel user • Scripts must parallel user behavior behavior • Tough to get AJAX-heavy • Accurate simulation of sites exactly right, maintain AJAX 12
  • 13. MULTI-MECHANIZE • FOSS (LGPL v3), based on mechanize • Load generation framework for VUs • Written in Python, scripted in Python • Heavyweight for bandwidth-bound tests, but stocked with py-goodness 13
  • 14. MULTI-MECHANIZE • Basic idea: • Write a few scripts that simulate user actions or paths • Specify how you want to run them: x VUs in parallel on script A, y on script B, ramping up, etc. • Run and watch 14
  • 15. A SIMPLE M-M SCRIPT get_index.py import  requests class  Transaction(object):    def  run(self):        r  =  requests.get(‘http://website.com/’)        r.raw.read() 15
  • 16. A SIMPLE PROJECT • A multi-mechanize “project” is a set of test scripts and a config that specifies how to run them: dan@host:~/mm/my_project$  ls  -­‐1   . .. config.cfg                #  config  file test_scripts/          #  your  tests  are  here results/                    #  result  files  go  here 16
  • 17. A SIMPLE PROJECT config.cfg [global] run_time:  60 rampup:  60 results_ts_interval:  60 console_logging:  off progress_bar:  on [user_group-­‐1] threads:  25 script:  get_index.py 17
  • 18. A FEW M-M FEATURES features.py import  requests import  time class  Transaction(object):    def  run(self):        r  =  requests.get(‘http://website.com/a’)        r.raw.read()        assert  (r.status_code  ==  200),  ‘not  200’        assert  (‘Error’  not  in  r.text)        t1  =  time.time()        r  =  requests.get(‘http://website.com/b’)        r.raw.read()        latency  =  time.time()  -­‐  t1        self.custom_timers[‘b’]  =  latency 18
  • 19. [  $  multimech-­‐run  example  ] 19
  • 20. INTERACTION login.py import  mechanize  as  m class  MyTransaction(object):    def  run(self):        br  =  m.Browser()        br.set_handle_equiv(True)        br.set_handle_gzip(True)        br.set_handle_redirect(True)        br.set_handle_referer(True)        br.set_handle_robots(False)        br.set_handle_refresh(m._http.HTTPRefreshProcessor(),                                                      max_time=1)        _  =  br.open(‘http://reddit.tlys.us’)        br.select_form(nr=1)        br.form['user']  =  u        br.form['passwd']  =  p        r  =  br.submit()        r.read() 20
  • 21. [  $  cat  more-­‐advanced-­‐example.py  ] [  $  multimech-­‐run  more-­‐advanced    ] 21
  • 22. GETTING INSIGHT • First, is the machine working hard? • Inspect basic resources: CPU/RAM/ IO • Ganglia/Munin/etc. 22
  • 23. MUNIN 23
  • 24. GETTING INSIGHT • Second, why is the machine working hard? • What is my app doing? • What are my databases doing? • How are my caches performing? 24
  • 25. REDDIT: A PYLONS APP nginx memcached uwsgi pylons postgresql cassandra queued jobs 25
  • 26. REDDIT: A PYLONS APP request start nginx memcached uwsgi pylons postgresql cassandra queued jobs request end 26
  • 27. REDDIT: A PYLONS APP request start nginx memcached uwsgi pylons postgresql cassandra queued jobs request end 27
  • 28. INSIDE THE APP PROFILING VS INSTRUMENTATION • Fine-grained analysis of • Gather curated set of Python code information • Easy to set up • Requires monkey-patching (or code edits) • No visibility into DB, • Can connect DB, cache cache, etc. performance to app • Distorts app performance • Little (tunable) overhead • profile, cProfile • django-debug-toolbar, statsd, Tracelytics, New Relic 28
  • 29. PROFILING 101 • ncalls: # of calls to method • cumtime: time spent in that method and all child calls • tottime: total time spent exclusively in that method • Try repoze.profile for WSGI ncalls tottime percall cumtime percall filename:lineno(function) 892048 12.643 0.000 17.676 0.000 thing.py:116(__getattr__) 14059/2526 9.475 0.001 34.159 0.014 template_helpers.py:181(_replace_render) 562060 7.384 0.000 7.384 0.000 {posix.stat} 204587/163113 6.908 0.000 51.302 0.000 filters.py:111(mako_websafe) 115192/109693 6.590 0.000 9.700 0.000 {method 'join' of 'str' objects} 1537933 6.584 0.000 15.437 0.000 registry.py:136(__getattr__) 1679803/1404938 5.294 0.000 11.767 0.000 {hasattr} 2579769/2434607 5.173 0.000 12.713 0.000 {getattr} 139 4.809 0.035 106.065 0.763 pages.py:1004(__init__) 8146 3.967 0.000 15.031 0.002 traceback.py:280(extract_stack) 43487 3.942 0.000 3.942 0.000 {method 'recv' of '_socket.socket' object 891579 3.759 0.000 21.430 0.000 thing.py:625(__getattr__) 72021 3.633 0.000 5.910 0.000 memcache.py:163(serverHashFunction) 201 3.319 0.017 38.667 0.192 pages.py:336(render) 392 3.236 0.008 3.236 0.008 {Cfilters.uspace_compress} 1610797 3.208 0.000 3.209 0.000 registry.py:177(_current_obj) 2017343 3.113 0.000 3.211 0.000 {isinstance} 29
  • 30. INSTRUMENTATION • DB queries • Cache usage • RPC calls • Optionally profile critical segments of code • Exceptions • Associate with particular codepaths or URLs 30
  • 34. THANKS! (any questions?) • Multi-mechanize: testutils.org/multi- mechanize/ • Email me: dan.kuebrich@gmail.com • My job: tracelytics.com 34
  • 35. APPENDIX • Multi-mechanize • Download: testutils.org/multi-mechanize • Development: github.com/cgoldberg/multi-mechanize • Mechanize: wwwsearch.sourceforge.net/mechanize/ • Reddit • Source: github.com/reddit/reddit • Demo load test: github.com/dankosaur/reddit-loadtest • RBU load testing • BrowserMob: browsermob.com/performance-testing • LoadStorm: loadstorm.com • New, but promising: github.com/detro/ghostdriver 35
  • 36. APPENDIX • Machine monitoring: • Ganglia: ganglia.sourceforge.net • Munin: munin-monitoring.org • Application monitoring: • repoze.profile: docs.repoze.org/profile/ • Django-Debug-Toolbar: github.com/django-debug- toolbar/django-debug-toolbar • Graphite: graphite.wikidot.com • and statsd: github.com/etsy/statsd • and django instrumentation: pypi.python.org/pypi/ django-statsd/1.8.0 • Tracelytics: tracelytics.com 36
  • 37. AND: TRACELYTICS FREE TRIAL We’ve got a 14-day trial; with only minutes to install, you’ll have plenty of time for load testing. No credit card required! http://tracelytics.com 37