Flag of Ukraine
SymfonyCasts stands united with the people of Ukraine

Blackfire Install: Agent, Probe, Chrome Extension

Video not working?

It looks like your browser may not support the H264 codec. If you're using Linux, try a different browser or try installing the gstreamer0.10-ffmpeg gstreamer0.10-plugins-good packages.

Thanks! This saves us from needing to use Flash or encode videos in multiple formats. And that let's us get back to making more videos :). But as always, please feel free to message us.

So let's get Blackfire installed on our local computer. Head over to https://blackfire.io and log in or register for a new account. As you can see, I've been busy using Blackfire already.

Agent & Probe: How it all Works

Click the Docs link on top... then installation on the left. Before we jump in and install everything, I want you to understand just a little bit about how this all works: understanding this helped me a bunch. If you want to skip this and head to the next video you can... just prepare to miss out on some cool diagrams!

Click the "main components of Blackfire" link and scroll down to find... woh! A diagram that shows you exactly how Blackfire works.

The Probe: PHP Extension that Collects Data

How about... we look at a simplified version. There are 3 things we need to install. The first is called the "probe", which is really just a PHP extension. You'll install this wherever your code is running - like on your local machine, and later on production. The probe's job is simple, but huge! It's responsible for collecting all of the information: all the function calls, how long each took, which function called which other function, how much memory did something take, network requests... you get the idea. By the way, the process of "collecting all the data" is sometimes called instrumentation... which I only mention so that if you see this fancy word... it hopefully won't confuse you... it confused me.

The Probe: Collector and Sender

The second thing we will need to install is called the "agent". This is a service - or "daemon" - that runs on your computer - or on your production machine. It... just sits there and waits. When the PHP extension - the probe - finishes collecting all the data, it sends that data to the agent. The agent does some processing on it - like removing unimportant information and anonymizing things - then ultimately sends that data to the Blackfire server. It's... the middleman.

So basically, the probe and agent work together to collect the info and send it to Blackfire.

The Browser Extension: Profiling Activator

The last piece you'll need to install is a browser extension. Remember: the probe is not profiling every single request. Normally, when a request comes in, it yawns... and does nothing. The browser extension's job is to activate profiling. It basically says:

Hey probe! Wake up! I'm going to make a request and I actually want you to do your thing - collect all the data and sent it to the agent. Cool? Text me when it's done.

And... that's it! This bottleneck-fighting superhero trio is our ticket to performance glory. Next, let's get them installed.

Leave a comment!

2
Login or Register to join the conversation

Is the Probe is simillar by idea as Zabbix on server ?

Reply

Hey Maxim,

I'm not sure what exactly is Zabbix because I've never used it before, but the Probe is a language extension that gathers the raw performance profiles. If it's something similar - I suppose so then :)

Cheers!

1 Reply
Cat in space

"Houston: no signs of life"
Start the conversation!

This tutorial can be used to learn how to profile any app - including Symfony 5.

What PHP libraries does this tutorial use?

// composer.json
{
    "require": {
        "php": "^7.1.3",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "blackfire/php-sdk": "^1.20", // v1.20.0
        "composer/package-versions-deprecated": "^1.11", // 1.11.99
        "doctrine/annotations": "^1.0", // v1.8.0
        "doctrine/doctrine-bundle": "^1.6.10|^2.0", // 1.11.2
        "doctrine/doctrine-migrations-bundle": "^1.3|^2.0", // v2.0.0
        "doctrine/orm": "^2.5.11", // v2.6.4
        "phpdocumentor/reflection-docblock": "^3.0|^4.0", // 4.3.2
        "sensio/framework-extra-bundle": "^5.4", // v5.5.1
        "symfony/console": "4.3.*", // v4.3.10
        "symfony/dotenv": "4.3.*", // v4.3.10
        "symfony/flex": "^1.9", // v1.18.7
        "symfony/form": "4.3.*", // v4.3.10
        "symfony/framework-bundle": "4.3.*", // v4.3.9
        "symfony/http-client": "4.3.*", // v4.3.10
        "symfony/property-access": "4.3.*", // v4.3.10
        "symfony/property-info": "4.3.*", // v4.3.10
        "symfony/security-bundle": "4.3.*", // v4.3.10
        "symfony/serializer": "4.3.*", // v4.3.10
        "symfony/twig-bundle": "4.3.*", // v4.3.10
        "symfony/validator": "4.3.*", // v4.3.10
        "symfony/webpack-encore-bundle": "^1.6", // v1.7.2
        "symfony/yaml": "4.3.*", // v4.3.10
        "twig/extensions": "^1.5" // v1.5.4
    },
    "require-dev": {
        "doctrine/doctrine-fixtures-bundle": "^3.2", // 3.2.2
        "easycorp/easy-log-handler": "^1.0.7", // v1.0.9
        "fzaninotto/faker": "^1.8", // v1.8.0
        "symfony/browser-kit": "4.3.*", // v4.3.10
        "symfony/css-selector": "4.3.*", // v4.3.10
        "symfony/debug-bundle": "4.3.*", // v4.3.10
        "symfony/maker-bundle": "^1.13", // v1.14.3
        "symfony/monolog-bundle": "^3.0", // v3.5.0
        "symfony/phpunit-bridge": "^5.0", // v5.0.3
        "symfony/stopwatch": "4.3.*", // v4.3.10
        "symfony/var-dumper": "4.3.*", // v4.3.10
        "symfony/web-profiler-bundle": "4.3.*" // v4.3.10
    }
}
userVoice