3. 3
Agenda
• Blackfire – Introduction
• Benefits of Blackfire
• Installation and Setup
• Blackfire Stacks (client, probe, agent and blackfire.io server)
• Blackfire workflow
• Understand different ways for blackfire profiling
• Analysis of blackfire reports and graph
4. 4
APM & Blackfire
APM
- That always runs on server to collect data for each and every request requests
- A continues service running to aggregate the code execution resource consumption data
Blackfire
- Blackfire is a profile that collect deep information at the time of investigating the
performance bottleneck and issues
- It only runs when we ask to run not always and hence do not cause any load on
server
5. 5
There are 3 parts of site performance :
- Time taken by SERVER to build the page to
generate response (Blackfire helps to analyze and
optimize the code executing on server)
- Time taken by NETWORK to transmit response data
- Time taken by browser to render the data on
FRONTEND
6. 6
What is Blackfire - Introduction
- Blackfire is a profiler, performance management solution
- Blackfire helps developers' profile, test, debug, and optimize performance of their applications
- Blackfire provides performance recommendations
- Blackfire helps to set and reach performance expectations through assertions
- Blackfire gathers a lot of data about how your code behaves at runtime
-Blackfire can be used at any step of an application’s lifecycle: during development, test, staging, and
production
- On application code execution, Blackfire gathers resource consumption data.
7. 7
Benefits of Blackfire
• Blackfire can be used on production, It adds no overhead for end users
• Safe to use on production
• No need to modify the code for instrumentations, On the fly Blackfire will gather
the resource consumption data only if profiling is requested by the authorized
blackfire agent
• Using Blackfire, we can profile HTTP requests via browsers or CLI (Web Pages,
Web Services, API calls)
• More proactive that APM, we set our performance expectation through
assertions
• Like unit testing, integration testing we can write our performance tests
scenarios
8. 8
Blackfire Stacks
• the Probe is a language extension that gathers the raw performance
profiles;
• the Agent is a server-side daemon that receives profiles from the Probe,
aggregates them, and forwards them to Blackfire;
• the Browser Extension is a web browser extension used mainly to
trigger profiling from a browser;
• the Client is the command line equivalent of the browser extension, it can
be used from anywhere;
• the Website is used to visualize the profiles.
https://blackfire.io/docs/reference-guide/faq#the-blackfire-stack
14. 14
Blackfire – Setup, Installation and
Upgrade
https://blackfire.io/docs/up-and-running/installation
https://blackfire.io/docs/up-and-running/update
15. 15
Sample Blackfire CLI command
Through CLI we can profile any commands, php script, API request, curl
request
https://blackfire.io/docs/cookbooks/profiling-http-via-cli
Profiling a PHP script is a matter of prefixing your command with blackfire run
$ blackfire run php my-script.php
$ blackfire run php my-script.php --your-script-options and arguments
To take average of several samples, use –samples
$ blackfire --samples 10 run php my-script.php
Blackfire uses curl as sub command to profile http request
blackfire curl http://example.com/
16. 16
Blackfire php-sdk (Manual Instrumentation)
https://blackfire.io/docs/integrations/php/sdk
The Blackfire PHP SDK can be added as a requirement to your project via Composer:
composer require blackfire/php-sdk
17. 17
Blackfire API Profiling
As of now there is no native Blackfire integration for API development application like
Postman, It is simple to profile requests using the Blackfire PHP SDK via an arbitrary
HTTP header that triggers profiling.
https://blackfire.io/docs/integrations/php/sdk
https://blackfire.io/docs/integrations/postman
18. 18
Blackfire Writing Tests
https://blackfire.io/docs/cookbooks/tests
File used : .blackfire.yaml on project root directory
Tests allow to write assertions on this data. We can write performance
tests with Blackfire by writing assertions on different performance metric
dimensions
Command to create file automatically:
blackfire bootstrap-tests
Online validator to validate blackfire’s yaml file
https://blackfire.io/docs/validator
19. Slide Title
Resources and Links
https://blackfire.io/
https://blackfire.io/docs/up-and-running/installation
https://symfonycasts.com/screencast/blackfire