[Blackfire] Unable to run Blackfire profiles due to load balancing
Kocal opened this issue · comments
Hi!
We are facing a load-balancing issue when running Blackfire Scenarios on our production application, which has 3 dynos:
<failure> └ <failure>Profiling progress is inconsistent (progress is going backward).
That happens for instance when the project's infrastructure is behind a load balancer.
Please read https://blackfire.io/docs/up-and-running/reverse-proxies#configuration-load-balancer
The Blackfire documentation about load balancer recommends to route all requests containing a header X-Blackfire-Query
to the same server, which AFAIK is not possible with Heroku.
Another solution is to configure which socket the Blackfire Agent should listen, e.g. tcp://0.0.0.0:8307
, which should be doable by configuring the env var BLACKFIRE_AGENT_SOCKET
, but it looks like this env var is hard-coded:
heroku-buildpack-php/support/build/blackfire
Lines 34 to 38 in eaecccf
What is the best way to fix this, does someone already has this issue?
Thanks!
Hi,
The tcp://0.0.0.0:8307
approach works by having a single Agent on one server (listening on all interfaces due to 0.0.0.0
), that all Probes then talk to over the network. That doesn't work on "normal" Heroku, since Dynos are isolated; it would be possible in a Private Space.
However, you should be able to enable https://devcenter.heroku.com/articles/session-affinity for your Heroku app to always route traffic from the same user to the same dyno.