Your SlideShare is downloading. ×
0
High performance websitesAn introduction into xDebug profiling, Kcachegrind and JMeter
About Us Axel Jung             Timo Schmidt Software Developer    Software Developer  AOE media GmbH         AOE media...
Preparation Install Virtualbox and import the t3dd2012 appliance (User &  Password: t3dd2012) You will find:   • Apache ...
Can you build a new   Yes, we can!  website for me?
But I expect a lot ofvisitors. Can you handle          them?            Yes, we can!
Yes, we can!Really?
...after inventing the next,  cutting edge, enterprise        architecture...
...and some* days of development...
The servers are notfast enough for your application ;)
xDebugINSTALL AND CONFIGURE
Install XDebug & KCachegrind●   Install xdebug(eg. apt-get install php5-xdebug)●   Install kcachegrind(eg. apt-get install...
Configure xDebug●   Configuration in    (/etc/php5/conf.d/xdebug.ini on Ubuntu)●   xdebug.profiler_enable_trigger = 1●   x...
Profiling●   By request:?XDEBUG_PROFILE●   All requests by htaccess:php_value xdebug.profiler_enable 1
Open with KCachegrind
KCachegrindOPTIMIZE WITH IDE AND MIND
Analyzing Cachegrinds●High self / medium self andmany calls =>High potential for optimization●   Early in call graph & not...
Hands on● There is an extension „slowstock“in the VM.● Open:„http://typo3.t3dd2012/index.php?id=2“ and analyze it with kca...
Total Time Cost 12769352   This code is very time consuming
Change 1 (SoapConversionRateProvider)SoapClient is instantiated everytime=> move to constructor
Change 1 (SoapConversionRateProvider)Before:/** * @param string $fromCurrency * @param string $toCurrency * @return float ...
Change 1 (SoapConversionRateProvider)After:/** @var SoapClient */protected $converter;/** @return void */public function _...
Total Time Cost 10910560 ( ~ -15%)    11,99 % is still much time :(
Change 2 (SoapConversionRateProvider)●  Conversion rates can be cached in APC cache to reduce webservicecalls.    – Inject...
Change 2 (SoapConversionRateProvider)Before:/** @var SoapClient */protected $converter;/** @return void */public function ...
Change 2 (SoapConversionRateProvider)After: /** @var Tx_Slowstock_System_Cache_ConversionRateCache */protected $cache; ......
Change 2 (SoapConversionRateProvider)After: /** @var Tx_Slowstock_System_Cache_ConversionRateCache */protected $cache; ......
Total Time Cost 5187627 ( ~ -50%) Much better, but lets look on the call  graph... do we need all that stuff?
The kcachegrind call graph
The kcachegrind call graphDo we need any TCA in Eid? No
Change 3 – Remove unneeded code:                    (Resources/Private/Eid/rates.php):Before:tslib_eidtools::connectDB();t...
Total Time Cost 2877900 ( ~ -45%)
Summary●       From 12769352 => 2877900 (-77%) with three changes ●       Additional Ideas:    ●    Reduce created fluid ...
JMeterhttp://jmeter.apache.org/
Why Jmeter?
JMeterBUILD A SIMPLE WEB TESTPLAN
JMeter Gui
Add Thread Group
Name Group
Add HTTP Defaults
Set Server
Add HTTP Sampler
Set Path
Add Listener
Start Tests
View Results
JMeterRECORD WITH PROXY
Add Recording Controller
Add Proxy Server
Exclude Assets
Start
Configure Browser
Browse
View results
JMeterADVANCED
Add Asserts
Match Text
Constant Timer
Set the Base
Summary Report
Graph Report
Define Variables
Use Variables
CSV Files
CSV Settings
Use CSV Vars
Command Line• /…/jmeter -n -t plan.jmx -l build/logs/testplan.jtl -j  build/logs/testplan.log
Jenkins and JMeter
Detail Report
Use Properties -p ${properties}
JMeter + CloudDISTRIBUTED TESTING
Start Server
jmeter.propertiesremote_hosts=127.0.0.1
Run Slaves
http://aws.amazon.com/AMAZON CLOUD
Create User
EC2
Create Key
Name Key
Download Key
Create Security Groups
Launch
Select AMI ami-3586be41
Minimum Small
Configure Firewall
Wait 15 Min
Get Adress
Connect
Start Cloud Tool
Start Instances
Wait for Slaves
Slave Log
Close JMeter
All Slave will be terminated
Slave AMI• ami-963e0ce2• Autostart JMeter im Server Mode
Costs
Want to know more?European HQ:   AOE media GmbH               Borsigstraße 3               65205 WiesbadenTel.:           ...
Performance measurement and tuning
Performance measurement and tuning
Performance measurement and tuning
Upcoming SlideShare
Loading in...5
×

Performance measurement and tuning

2,193

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,193
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
31
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "Performance measurement and tuning"

  1. 1. High performance websitesAn introduction into xDebug profiling, Kcachegrind and JMeter
  2. 2. About Us Axel Jung  Timo Schmidt Software Developer  Software Developer AOE media GmbH AOE media GmbH
  3. 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. 4. Can you build a new Yes, we can! website for me?
  5. 5. But I expect a lot ofvisitors. Can you handle them? Yes, we can!
  6. 6. Yes, we can!Really?
  7. 7. ...after inventing the next, cutting edge, enterprise architecture...
  8. 8. ...and some* days of development...
  9. 9. The servers are notfast enough for your application ;)
  10. 10. xDebugINSTALL AND CONFIGURE
  11. 11. Install XDebug & KCachegrind● Install xdebug(eg. apt-get install php5-xdebug)● Install kcachegrind(eg. apt-get install kcachegrind)
  12. 12. Configure xDebug● Configuration in (/etc/php5/conf.d/xdebug.ini on Ubuntu)● xdebug.profiler_enable_trigger = 1● xdebug.profiler_output_dir = /..
  13. 13. Profiling● By request:?XDEBUG_PROFILE● All requests by htaccess:php_value xdebug.profiler_enable 1
  14. 14. Open with KCachegrind
  15. 15. KCachegrindOPTIMIZE WITH IDE AND MIND
  16. 16. Analyzing Cachegrinds●High self / medium self andmany calls =>High potential for optimization● Early in call graph & not needed =>High potential for optimization
  17. 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. 18. Total Time Cost 12769352 This code is very time consuming
  19. 19. Change 1 (SoapConversionRateProvider)SoapClient is instantiated everytime=> move to constructor
  20. 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. 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. 22. Total Time Cost 10910560 ( ~ -15%) 11,99 % is still much time :(
  23. 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. 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. 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. 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. 27. Total Time Cost 5187627 ( ~ -50%) Much better, but lets look on the call graph... do we need all that stuff?
  28. 28. The kcachegrind call graph
  29. 29. The kcachegrind call graphDo we need any TCA in Eid? No
  30. 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. 31. Total Time Cost 2877900 ( ~ -45%)
  32. 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. 33. JMeterhttp://jmeter.apache.org/
  34. 34. Why Jmeter?
  35. 35. JMeterBUILD A SIMPLE WEB TESTPLAN
  36. 36. JMeter Gui
  37. 37. Add Thread Group
  38. 38. Name Group
  39. 39. Add HTTP Defaults
  40. 40. Set Server
  41. 41. Add HTTP Sampler
  42. 42. Set Path
  43. 43. Add Listener
  44. 44. Start Tests
  45. 45. View Results
  46. 46. JMeterRECORD WITH PROXY
  47. 47. Add Recording Controller
  48. 48. Add Proxy Server
  49. 49. Exclude Assets
  50. 50. Start
  51. 51. Configure Browser
  52. 52. Browse
  53. 53. View results
  54. 54. JMeterADVANCED
  55. 55. Add Asserts
  56. 56. Match Text
  57. 57. Constant Timer
  58. 58. Set the Base
  59. 59. Summary Report
  60. 60. Graph Report
  61. 61. Define Variables
  62. 62. Use Variables
  63. 63. CSV Files
  64. 64. CSV Settings
  65. 65. Use CSV Vars
  66. 66. Command Line• /…/jmeter -n -t plan.jmx -l build/logs/testplan.jtl -j build/logs/testplan.log
  67. 67. Jenkins and JMeter
  68. 68. Detail Report
  69. 69. Use Properties -p ${properties}
  70. 70. JMeter + CloudDISTRIBUTED TESTING
  71. 71. Start Server
  72. 72. jmeter.propertiesremote_hosts=127.0.0.1
  73. 73. Run Slaves
  74. 74. http://aws.amazon.com/AMAZON CLOUD
  75. 75. Create User
  76. 76. EC2
  77. 77. Create Key
  78. 78. Name Key
  79. 79. Download Key
  80. 80. Create Security Groups
  81. 81. Launch
  82. 82. Select AMI ami-3586be41
  83. 83. Minimum Small
  84. 84. Configure Firewall
  85. 85. Wait 15 Min
  86. 86. Get Adress
  87. 87. Connect
  88. 88. Start Cloud Tool
  89. 89. Start Instances
  90. 90. Wait for Slaves
  91. 91. Slave Log
  92. 92. Close JMeter
  93. 93. All Slave will be terminated
  94. 94. Slave AMI• ami-963e0ce2• Autostart JMeter im Server Mode
  95. 95. Costs
  96. 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
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×