Performance and Scalability Testing with Python and Multi-Mechanize
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Performance and Scalability Testing with Python and Multi-Mechanize

on

  • 17,161 views

Performance and Scalability Testing

Performance and Scalability Testing
with Python and Multi-Mechanize.

visit http://multimechanize.com

Statistics

Views

Total Views
17,161
Views on SlideShare
10,256
Embed Views
6,905

Actions

Likes
9
Downloads
122
Comments
0

64 Embeds 6,905

http://coreygoldberg.blogspot.com 4246
http://architects.dzone.com 1363
http://joe-dev.blogspot.tw 472
http://feeds.feedburner.com 189
http://java.dzone.com 177
http://coreygoldberg.blogspot.in 103
http://joe-dev.blogspot.com 73
http://python.dzone.com 21
http://coreygoldberg.blogspot.co.uk 20
http://coreygoldberg.blogspot.fr 18
http://www.coreygoldberg.blogspot.com 18
http://coreygoldberg.blogspot.de 16
http://coreygoldberg.blogspot.com.br 15
http://coreygoldberg.blogspot.nl 15
http://coreygoldberg.blogspot.ca 14
http://coreygoldberg.blogspot.com.au 12
http://coreygoldberg.blogspot.mx 10
http://joe-dev.blogspot.jp 8
http://coreygoldberg.blogspot.com.es 8
http://coreygoldberg.blogspot.ru 7
http://translate.googleusercontent.com 6
http://coreygoldberg.blogspot.cz 5
http://coreygoldberg.blogspot.se 5
http://coreygoldberg.blogspot.co.il 5
http://coreygoldberg.blogspot.hk 4
http://coreygoldberg.blogspot.tw 4
http://coreygoldberg.blogspot.fi 4
http://feeds.nytimes.com 4
http://coreygoldberg.blogspot.it 4
http://coreygoldberg.blogspot.no 3
http://coreygoldberg.blogspot.com.ar 3
http://coreygoldberg.blogspot.be 3
http://cloud.feedly.com 3
http://coreygoldberg.blogspot.hu 3
http://coreygoldberg.blogspot.pt 3
http://webcache.googleusercontent.com 3
http://coreygoldberg.blogspot.jp 3
http://207.46.192.232 2
http://joe-dev.blogspot.hk 2
http://rritw.com 2
http://static.slidesharecdn.com 2
http://www.rritw.com 2
http://coreygoldberg.blogspot.co.nz 2
http://digg.com 2
http://coreygoldberg.blogspot.ch 2
http://web.archive.org 1
http://www.netvibes.com 1
http://news.google.com 1
http://joe-dev.blogspot.de 1
http://www.google.com.tw 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

CC Attribution License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Performance and Scalability Testing with Python and Multi-Mechanize Presentation Transcript

  • 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
  • 14. Running a Test
  • 15. Results Reports
  • 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