24
Performance Optimization Jitendra Singh Software Engineer

Magento Meetup New Delhi- Performance Optimization

Embed Size (px)

Citation preview

Page 1: Magento Meetup New Delhi- Performance Optimization

Performance OptimizationJitendra SinghSoftware Engineer

Page 2: Magento Meetup New Delhi- Performance Optimization

Why performance

is so important

40% of users leave a website that take more than 3 seconds to load

Page 3: Magento Meetup New Delhi- Performance Optimization

Measuring Performance

1.The memory consumption

2.The number of times function are called

3.The duration of function’s execution

4.The number of SQL queries

Page 4: Magento Meetup New Delhi- Performance Optimization

Performance Testing Tools

1.Xdebug

2.KCachegrind

3.Xhprof

4.Blackfire etc.

Page 5: Magento Meetup New Delhi- Performance Optimization

What is Blackfire

Blackfire is a web based Performance Management Solution. Blackfire can be used at any stage of your application’s lifecycle: during development, test and production.

Page 6: Magento Meetup New Delhi- Performance Optimization

Installation

1.Install the blackfire-agent package (sudo apt-get install blackfire-agent)

2.Configure you blackfire credentials (sudo blackfire-agent -register)

3.Install the blackfire-agent package (sudo apt-get install blackfire-agent)

4.Run the config command to initialize the client (blackfire config)

5.Restart Blackfire (sudo /etc/init.d/blackfire-agent restart)

Page 7: Magento Meetup New Delhi- Performance Optimization

Triggering Blackfire Profile

1.Blackfire Companion (Google Chrome extension)

2.Blackfire Client (CLI)

Page 8: Magento Meetup New Delhi- Performance Optimization

**Logos and Trademarks are owned by their respective owners

Page 9: Magento Meetup New Delhi- Performance Optimization

**Logos and Trademarks are owned by their respective owners

Page 10: Magento Meetup New Delhi- Performance Optimization
Page 11: Magento Meetup New Delhi- Performance Optimization

**Logos and Trademarks are owned by their respective owners

Page 12: Magento Meetup New Delhi- Performance Optimization

**Logos and Trademarks are owned by their respective owners

Page 13: Magento Meetup New Delhi- Performance Optimization

Profile Ajax Request

Page 14: Magento Meetup New Delhi- Performance Optimization

**Logos and Trademarks are owned by their respective owners

Page 15: Magento Meetup New Delhi- Performance Optimization

**Logos and Trademarks are owned by their respective owners

Page 16: Magento Meetup New Delhi- Performance Optimization

**Logos and Trademarks are owned by their respective owners

Page 17: Magento Meetup New Delhi- Performance Optimization

**Logos and Trademarks are owned by their respective owners

Page 18: Magento Meetup New Delhi- Performance Optimization

**Logos and Trademarks are owned by their respective owners

Page 19: Magento Meetup New Delhi- Performance Optimization

Profiling CLI commands

1. $ blackfire --samples 10 run php my-script.php2. $ blackfire --reference=7 run php my-script.php3. $ blackfire --json run php my-script.php

Page 20: Magento Meetup New Delhi- Performance Optimization

Profiling part of your

code

1. $blackfire = new \Blackfire\Client();2. $probe = $blackfire->createProbe();

// some PHP code you want to profile

$profile = $blackfire->endProbe($probe);3. // store the profile UUID

$uuid = $probe->getRequest()->getUuid();

// retrieve the profile later on$profile = $blackfire->getProfile($uuid);

Page 21: Magento Meetup New Delhi- Performance Optimization

Assertion

An assertion is an expression that must return a Boolean (true if the assertion succeeds,false otherwise).

An assertion is made of metric values, variables, operators"main.peak_memory < 10mb""metrics.sql.queries.count == 0""main.peak_memory < vars.max_memory"

Page 22: Magento Meetup New Delhi- Performance Optimization

Writing Assertion

Page 23: Magento Meetup New Delhi- Performance Optimization

Testing with custom metrics

Page 24: Magento Meetup New Delhi- Performance Optimization

Thanks