heroku / heroku-buildpack-php

Heroku's buildpack for PHP applications.

Home Page:https://devcenter.heroku.com/categories/php

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[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:

tee ${OUT_PREFIX}/bin/export.blackfire.sh > ${OUT_PREFIX}/bin/profile.blackfire.sh <<'EOF'
# hard-code these two; no need for users to override them
export BLACKFIRE_LOG_FILE=stderr
export BLACKFIRE_AGENT_SOCKET="unix:///app/.heroku/php/var/blackfire/run/agent.sock"
EOF

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.