Performance measurement and tuning

  • 1,964 views
Uploaded on

 

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,964
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
29
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. High performance websitesAn introduction into xDebug profiling, Kcachegrind and JMeter
  • 2. About Us Axel Jung  Timo Schmidt Software Developer  Software Developer AOE media GmbH AOE media GmbH
  • 3. Preparation Install Virtualbox and import the t3dd2012 appliance (User & Password: t3dd2012) You will find: • Apache with xdebug and apc • Jmeter • Kcachegrind • PHPStorm There are two vhost: • typo3.t3dd2012 and playground.t3dd2012
  • 4. Can you build a new Yes, we can! website for me?
  • 5. But I expect a lot ofvisitors. Can you handle them? Yes, we can!
  • 6. Yes, we can!Really?
  • 7. ...after inventing the next, cutting edge, enterprise architecture...
  • 8. ...and some* days of development...
  • 9. The servers are notfast enough for your application ;)
  • 10. xDebugINSTALL AND CONFIGURE
  • 11. Install XDebug & KCachegrind● Install xdebug(eg. apt-get install php5-xdebug)● Install kcachegrind(eg. apt-get install kcachegrind)
  • 12. Configure xDebug● Configuration in (/etc/php5/conf.d/xdebug.ini on Ubuntu)● xdebug.profiler_enable_trigger = 1● xdebug.profiler_output_dir = /..
  • 13. Profiling● By request:?XDEBUG_PROFILE● All requests by htaccess:php_value xdebug.profiler_enable 1
  • 14. Open with KCachegrind
  • 15. KCachegrindOPTIMIZE WITH IDE AND MIND
  • 16. Analyzing Cachegrinds●High self / medium self andmany calls =>High potential for optimization● Early in call graph & not needed =>High potential for optimization
  • 17. Hands on● There is an extension „slowstock“in the VM.● Open:„http://typo3.t3dd2012/index.php?id=2“ and analyze it with kcachegrind.
  • 18. Total Time Cost 12769352 This code is very time consuming
  • 19. Change 1 (SoapConversionRateProvider)SoapClient is instantiated everytime=> move to constructor
  • 20. Change 1 (SoapConversionRateProvider)Before:/** * @param string $fromCurrency * @param string $toCurrency * @return float */public function getConversionRate($fromCurrency, $toCurrency) { $converter = new SoapClient($this->wsdl); $in = new stdClass(); $in->FromCurrency = $fromCurrency; $in->ToCurrency = $toCurrency; $out = $converter->ConversionRate($in); $result = $out->ConversionRateResult; return $result;}
  • 21. Change 1 (SoapConversionRateProvider)After:/** @var SoapClient */protected $converter;/** @return void */public function __construct() { $this->converter = new SoapClient($this->wsdl);}/** * @param string $fromCurrency * @param string $toCurrency * @return float */public function getConversionRate($fromCurrency, $toCurrency) { $in = new stdClass(); $in->FromCurrency = $fromCurrency; $in->ToCurrency = $toCurrency; $out = $this->converter->ConversionRate($in); $result = $out->ConversionRateResult; return $result;}
  • 22. Total Time Cost 10910560 ( ~ -15%) 11,99 % is still much time :(
  • 23. Change 2 (SoapConversionRateProvider)● Conversion rates can be cached in APC cache to reduce webservicecalls. – Inject „ConversionRateCache“ into SoapConversionRateProvider. – Use the cache in the convert method.
  • 24. Change 2 (SoapConversionRateProvider)Before:/** @var SoapClient */protected $converter;/** @return void */public function __construct() { $this->converter = new SoapClient($this->wsdl);}/** * @param string $fromCurrency * @param string $toCurrency * @return float */public function getConversionRate($fromCurrency, $toCurrency) { $in = new stdClass(); $in->FromCurrency = $fromCurrency; $in->ToCurrency = $toCurrency; $out = $this->converter->ConversionRate($in); $result = $out->ConversionRateResult; return $result;}
  • 25. Change 2 (SoapConversionRateProvider)After: /** @var Tx_Slowstock_System_Cache_ConversionRateCache */protected $cache; .../** @param Tx_Slowstock_System_Cache_ConversionRateCache $cache */public function injectRateCache(Tx_Slowstock_System_Cache_ConversionRateCache $cache) { $this->cache = $cache;}…public function getConversionRate($fromCurrency, $toCurrency) { $cacheKey = $fromCurrency.-.$toCurrency; if(!$this->cache->has($cacheKey)) { $in = new stdClass(); $in->FromCurrency = $fromCurrency; $in->ToCurrency = $toCurrency; $out = $this->converter->ConversionRate($in); $result = $out->ConversionRateResult; $this->cache->set($cacheKey, $result); } return $this->cache->get($cacheKey);}
  • 26. Change 2 (SoapConversionRateProvider)After: /** @var Tx_Slowstock_System_Cache_ConversionRateCache */protected $cache; .../** @param Tx_Slowstock_System_Cache_ConversionRateCache $cache */public function injectRateCache(Tx_Slowstock_System_Cache_ConversionRateCache $cache) { $this->cache = $cache;}…public function getConversionRate($fromCurrency, $toCurrency) { $cacheKey = $fromCurrency.-.$toCurrency; if(!$this->cache->has($cacheKey)) { $in = new stdClass(); $in->FromCurrency = $fromCurrency; $in->ToCurrency = $toCurrency; $out = $this->converter->ConversionRate($in); $result = $out->ConversionRateResult; $this->cache->set($cacheKey, $result); } return $this->cache->get($cacheKey);}
  • 27. Total Time Cost 5187627 ( ~ -50%) Much better, but lets look on the call graph... do we need all that stuff?
  • 28. The kcachegrind call graph
  • 29. The kcachegrind call graphDo we need any TCA in Eid? No
  • 30. Change 3 – Remove unneeded code: (Resources/Private/Eid/rates.php):Before:tslib_eidtools::connectDB();tslib_eidtools::initTCA();$TSFE = t3lib_div::makeInstance(tslib_fe, $GLOBALS[TYPO3_CONF_VARS], ...);After:tslib_eidtools::connectDB();$TSFE = t3lib_div::makeInstance(tslib_fe, $GLOBALS[TYPO3_CONF_VARS], ...);
  • 31. Total Time Cost 2877900 ( ~ -45%)
  • 32. Summary● From 12769352 => 2877900 (-77%) with three changes ● Additional Ideas: ● Reduce created fluid objects by implementing static fluid view helpers (examples in fluid core) ● Cache reverse conversion rate (1/rate) ● Use APC Cache Backend for TYPO3 and Extbase caches
  • 33. JMeterhttp://jmeter.apache.org/
  • 34. Why Jmeter?
  • 35. JMeterBUILD A SIMPLE WEB TESTPLAN
  • 36. JMeter Gui
  • 37. Add Thread Group
  • 38. Name Group
  • 39. Add HTTP Defaults
  • 40. Set Server
  • 41. Add HTTP Sampler
  • 42. Set Path
  • 43. Add Listener
  • 44. Start Tests
  • 45. View Results
  • 46. JMeterRECORD WITH PROXY
  • 47. Add Recording Controller
  • 48. Add Proxy Server
  • 49. Exclude Assets
  • 50. Start
  • 51. Configure Browser
  • 52. Browse
  • 53. View results
  • 54. JMeterADVANCED
  • 55. Add Asserts
  • 56. Match Text
  • 57. Constant Timer
  • 58. Set the Base
  • 59. Summary Report
  • 60. Graph Report
  • 61. Define Variables
  • 62. Use Variables
  • 63. CSV Files
  • 64. CSV Settings
  • 65. Use CSV Vars
  • 66. Command Line• /…/jmeter -n -t plan.jmx -l build/logs/testplan.jtl -j build/logs/testplan.log
  • 67. Jenkins and JMeter
  • 68. Detail Report
  • 69. Use Properties -p ${properties}
  • 70. JMeter + CloudDISTRIBUTED TESTING
  • 71. Start Server
  • 72. jmeter.propertiesremote_hosts=127.0.0.1
  • 73. Run Slaves
  • 74. http://aws.amazon.com/AMAZON CLOUD
  • 75. Create User
  • 76. EC2
  • 77. Create Key
  • 78. Name Key
  • 79. Download Key
  • 80. Create Security Groups
  • 81. Launch
  • 82. Select AMI ami-3586be41
  • 83. Minimum Small
  • 84. Configure Firewall
  • 85. Wait 15 Min
  • 86. Get Adress
  • 87. Connect
  • 88. Start Cloud Tool
  • 89. Start Instances
  • 90. Wait for Slaves
  • 91. Slave Log
  • 92. Close JMeter
  • 93. All Slave will be terminated
  • 94. Slave AMI• ami-963e0ce2• Autostart JMeter im Server Mode
  • 95. Costs
  • 96. Want to know more?European HQ: AOE media GmbH Borsigstraße 3 65205 WiesbadenTel.: +49 (0)6122 70 70 7 - 0Fax: +49 (0)6122 70 70 7 - 199E-Mail: postfach@aoemedia.deWeb: http://www.aoemedia.de