SlideShare a Scribd company logo
Performance and Scalability Testing with Python and Multi-Mechanize Corey Goldberg   2011 web:  goldb.org email:  [email_address] twitter:  @cgoldberg multimechanize.com
Multi-Mechanize Open Source (LGPLv3) Started Development in 2010 Python 2 (2.6+) Project Hosted on Google Code (SVN) Website:  multimechanize.com Download Code Samples / Script Dev Guide Wiki Discussion Group
What is Multi-Mechanize? "Python framework for performance and load testing remote API's" Enables you to: run simultaneous client scripts to generate workload against a remote service run transactions at an increasing series of load levels against your API and measure performance simulate realistic and projected API usage
Who is Multi-Mechanize For? Developers Testers Ops ... who need to test and tune the performance and scalability of a web site or API service Assumptions: You know how to code in Python You understand basic performance testing
Testing for Performance & Scalability You have a remote API or website and need to: stress test server and network infrastructure find application bottlenecks expose errors under load performance benchmarks capacity planning
Which API's Can You Test? You write the virtual user (client) scripts in Python, so any remote protocol/lib you want: Web/HTTP Raw HTTP (urllib2, httplib) Web Forms (mechanize) REST/SOAP/XMLRPC Sockets Database, NoSQL, Cache Any Python API
Things I Like Free Runs on multiple platforms (nix, win) Python code base Scripts are in Python (batteries included, python libraries) Scalable load generator Automatic report generation Aggregate stats (response times, throughput, percentiles) Graphs (scatter, time-series)
Inside Multi-Mechanize Multi-process/Multi-threaded Test Harness Virtual User Scripting in Python Configurable Test Runner Report Generator Input: Virtual User Test Scripts, Config File Output:  HTML Report with PNG images (graphs)
Virtual User Scripting You create test scripts in Python for Multi-Mechanize to run.   Each test script must implement a  Transaction() class . This class must implement a  run() method . So a basic test script consists of: class Transaction:      def run(self):          # do something here
Virtual User Scripting During a test run, your Transaction() class is instantiated once, and then its run() method is called repeatedly: class Transaction:      def __init__(self):          # this gets called once           def run(self):          # this gets called repeatedly
Virtual User Scripting A full script that will issue an HTTP GET using urllib2:      import urllib2 class Transaction(object):      def run(self):          url = 'http://www.example.com/'          urllib2.urlopen(url).read()
Virtual User Scripting web request with timer and assertions: import mechanize import time class Transaction:      def run(self):          self.custom_timers = {}          br = mechanize.Browser()          br.set_handle_robots(False)                   start_timer = time.time()          resp = br.open('http://www.example.com/')          resp.read()          latency = time.time() - start_timer                   self.custom_timers['Example_Homepage'] = latency                   assert (resp.code == 200), 'Bad HTTP Response'          assert ('Example Web Page' in resp.get_data()),               'Failed Content Verification'
Test Configuration sample config file:    [global]    run_time: 300    rampup: 300    console_logging: off    results_ts_interval: 60       [user_group-1]    threads: 10    script: search_simple.py       [user_group-2]    threads: 5    script: search_complex.py
Running a Test
Results Reports
Results Reports (Stats) test summary transaction timers custom timers (from instrumented client code) time-series/interval data counts rate/throughput response times average, min, max, stdev percentiles (80th, 90th, 95th)
Results Reports (Graphs) response time scatter plot:
Results Reports (Graphs) throughput time-series plot:
Results Reports (Graphs) latency time-series plot:
The End visit:   http://multimechanize.com

More Related Content

PDF
Development matters-final-print-amended
PPT
Chapter 4 Guidance in the Classroom
PDF
NowyCENNIKfankfurterki.pdf
PDF
Python Load Testing - Pygotham 2012
PDF
Plotting data with python and pylab
PDF
OSMC 2015: Monitoring at Spotify-When things go ping in the night by Martin Parm
PDF
2016 metrics-as-culture
PDF
Monitoring your Python with Prometheus (Python Ireland April 2015)
Development matters-final-print-amended
Chapter 4 Guidance in the Classroom
NowyCENNIKfankfurterki.pdf
Python Load Testing - Pygotham 2012
Plotting data with python and pylab
OSMC 2015: Monitoring at Spotify-When things go ping in the night by Martin Parm
2016 metrics-as-culture
Monitoring your Python with Prometheus (Python Ireland April 2015)

Similar to Performance and Scalability Testing with Python and Multi-Mechanize (20)

PDF
Automação de testes funcionais com Python e Mechanize
PDF
TDC2016SP - Automação de testes funcionais com Python e Mechanize
PDF
WebPagetest Power Users - Velocity 2014
PDF
multi-mechanize testing certification
PDF
Benchmarking Performance and Scalability with Web Stress
PPT
Performance Testing
PPT
Performance testing with loadrunner by kc
PPTX
Performance testingfromthecloud_usingBlazemeter
PDF
LoadRunner Performance Testing
PDF
Lrpc training
PPT
Iasi code camp 12 october 2013 performance testing for web applications with...
PDF
Load Testing with JMeter, BlazeMeter, New Relic
PDF
Downloading a Billion Files in Python
DOC
LoadTracer
PDF
Neotys PAC 2018 - Jonathon Wright
PPTX
PERFORMANCE TESTING USING LOAD RUNNER
PPTX
ENASE 2013 - SEM - (Francia) From Functional Test Scripts to Performance Test...
KEY
PyCon US 2012 - Web Server Bottlenecks and Performance Tuning
PDF
Continuous Performance Testing for Microservices
PDF
Telemetry indepth
Automação de testes funcionais com Python e Mechanize
TDC2016SP - Automação de testes funcionais com Python e Mechanize
WebPagetest Power Users - Velocity 2014
multi-mechanize testing certification
Benchmarking Performance and Scalability with Web Stress
Performance Testing
Performance testing with loadrunner by kc
Performance testingfromthecloud_usingBlazemeter
LoadRunner Performance Testing
Lrpc training
Iasi code camp 12 october 2013 performance testing for web applications with...
Load Testing with JMeter, BlazeMeter, New Relic
Downloading a Billion Files in Python
LoadTracer
Neotys PAC 2018 - Jonathon Wright
PERFORMANCE TESTING USING LOAD RUNNER
ENASE 2013 - SEM - (Francia) From Functional Test Scripts to Performance Test...
PyCon US 2012 - Web Server Bottlenecks and Performance Tuning
Continuous Performance Testing for Microservices
Telemetry indepth
Ad

Recently uploaded (20)

PPTX
Cloud computing and distributed systems.
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Approach and Philosophy of On baking technology
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Spectroscopy.pptx food analysis technology
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
cuic standard and advanced reporting.pdf
PDF
Encapsulation theory and applications.pdf
PPT
Teaching material agriculture food technology
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Electronic commerce courselecture one. Pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
Cloud computing and distributed systems.
Advanced methodologies resolving dimensionality complications for autism neur...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Dropbox Q2 2025 Financial Results & Investor Presentation
Approach and Philosophy of On baking technology
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Spectroscopy.pptx food analysis technology
Unlocking AI with Model Context Protocol (MCP)
cuic standard and advanced reporting.pdf
Encapsulation theory and applications.pdf
Teaching material agriculture food technology
Encapsulation_ Review paper, used for researhc scholars
Reach Out and Touch Someone: Haptics and Empathic Computing
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Electronic commerce courselecture one. Pdf
Network Security Unit 5.pdf for BCA BBA.
Digital-Transformation-Roadmap-for-Companies.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Programs and apps: productivity, graphics, security and other tools
Ad

Performance and Scalability Testing with Python and Multi-Mechanize

  • 1. Performance and Scalability Testing with Python and Multi-Mechanize Corey Goldberg   2011 web: goldb.org email: [email_address] twitter: @cgoldberg multimechanize.com
  • 2. Multi-Mechanize Open Source (LGPLv3) Started Development in 2010 Python 2 (2.6+) Project Hosted on Google Code (SVN) Website: multimechanize.com Download Code Samples / Script Dev Guide Wiki Discussion Group
  • 3. What is Multi-Mechanize? "Python framework for performance and load testing remote API's" Enables you to: run simultaneous client scripts to generate workload against a remote service run transactions at an increasing series of load levels against your API and measure performance simulate realistic and projected API usage
  • 4. Who is Multi-Mechanize For? Developers Testers Ops ... who need to test and tune the performance and scalability of a web site or API service Assumptions: You know how to code in Python You understand basic performance testing
  • 5. Testing for Performance & Scalability You have a remote API or website and need to: stress test server and network infrastructure find application bottlenecks expose errors under load performance benchmarks capacity planning
  • 6. Which API's Can You Test? You write the virtual user (client) scripts in Python, so any remote protocol/lib you want: Web/HTTP Raw HTTP (urllib2, httplib) Web Forms (mechanize) REST/SOAP/XMLRPC Sockets Database, NoSQL, Cache Any Python API
  • 7. Things I Like Free Runs on multiple platforms (nix, win) Python code base Scripts are in Python (batteries included, python libraries) Scalable load generator Automatic report generation Aggregate stats (response times, throughput, percentiles) Graphs (scatter, time-series)
  • 8. Inside Multi-Mechanize Multi-process/Multi-threaded Test Harness Virtual User Scripting in Python Configurable Test Runner Report Generator Input: Virtual User Test Scripts, Config File Output:  HTML Report with PNG images (graphs)
  • 9. Virtual User Scripting You create test scripts in Python for Multi-Mechanize to run.   Each test script must implement a Transaction() class . This class must implement a run() method . So a basic test script consists of: class Transaction:     def run(self):         # do something here
  • 10. Virtual User Scripting During a test run, your Transaction() class is instantiated once, and then its run() method is called repeatedly: class Transaction:     def __init__(self):         # this gets called once          def run(self):         # this gets called repeatedly
  • 11. Virtual User Scripting A full script that will issue an HTTP GET using urllib2:      import urllib2 class Transaction(object):     def run(self):         url = 'http://www.example.com/'         urllib2.urlopen(url).read()
  • 12. Virtual User Scripting web request with timer and assertions: import mechanize import time class Transaction:     def run(self):         self.custom_timers = {}         br = mechanize.Browser()         br.set_handle_robots(False)                  start_timer = time.time()         resp = br.open('http://www.example.com/')         resp.read()         latency = time.time() - start_timer                  self.custom_timers['Example_Homepage'] = latency                  assert (resp.code == 200), 'Bad HTTP Response'         assert ('Example Web Page' in resp.get_data()),              'Failed Content Verification'
  • 13. Test Configuration sample config file:   [global]   run_time: 300   rampup: 300   console_logging: off   results_ts_interval: 60      [user_group-1]   threads: 10   script: search_simple.py      [user_group-2]   threads: 5   script: search_complex.py
  • 16. Results Reports (Stats) test summary transaction timers custom timers (from instrumented client code) time-series/interval data counts rate/throughput response times average, min, max, stdev percentiles (80th, 90th, 95th)
  • 17. Results Reports (Graphs) response time scatter plot:
  • 18. Results Reports (Graphs) throughput time-series plot:
  • 19. Results Reports (Graphs) latency time-series plot:
  • 20. The End visit:   http://multimechanize.com