Search code examples
heroku

Make a request to a specific instance in heroku cloud


Some cloud provider services allow to make a request to a specific instance. Is this possible to do in heroku? Looking at the docs i cant see any header to achieve this.


Solution

  • If by "make a request" you mean an HTTP request, no, this is not possible. Heroku's routers distribute HTTP traffic between dynos randomly:

    Routers use a random selection algorithm for balancing HTTP requests across web dynos. In cases where there are a large number of dynos, the algorithm may optionally bias its selection towards dynos resident in the same AWS availability zone as the router making the selection.

    However, if you mean "connect via SSH", you can use heroku ps:exec:

    Heroku Exec is a feature for creating secure TCP and SSH tunnels into a dyno. It allows for SSH sessions, port forwarding, remote debugging, and inspection with popular Java diagnostic tools.

    By default, Heroku Exec connects to your web.1 dyno, but you can optionally specify a dyno:

    heroku ps:exec --dyno=web.2
    Establishing credentials... done
    Connecting to web.2 on ⬢ your-app...
    ~ $