1

I run 4 dynos with nodejs app on it under same subdomain (Example: app.website.com). I need to send to all my dynos request from other dyno app (other domain: admin.website.com), also nodejs app. All dynos should remove some cached data in memory on command from admin server.

If I send http request to app.website.com only one of the dynos get it (because of the load balancer).

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
Stan
  • 13
  • 3
  • "I need to send to all my dynos request from other dyno app"—no, you don't. "ll dynos should remove some cached data in memory on command from admin server"—the correct solution is not to cache things on the dyno in the first place. Use a shared cache. – ChrisGPT was on strike Feb 04 '23 at 15:22
  • @Christ +1 for pointing out that its an XY-Problem. But caching centrally is certainly not the only valid answer. There are good reasons for distributed in-memory caching. The real question is "how to distribute cache purge events from an admin server to n application nodes on heroku?" – simon.ro Feb 04 '23 at 16:46

1 Answers1

1

In Herokus "common runtime" its neither possible to connect to individual dynos from the outside, nor can you send http requests from one dyno to another. (See https://devcenter.heroku.com/articles/dynos#common-runtime-networking). In Herokus private space on the other hand the later would be possible, because all dynos form a VPN. (See https://devcenter.heroku.com/articles/dynos#private-spaces-runtime-networking)

Instead of trying to send a cache purge event to all dynos using http, it would probably be a better idea to change the setup. You could use a central component, e.g. a message queue, to which both your admin dynos and your app dynos can connect. The admin app could then dispatch cache purge events, which your app consumes. If you don't want to expand your infrastructure unnecessarily, but you already have any other central storage (e.g. a database) connected, you could also use that.

simon.ro
  • 2,984
  • 2
  • 22
  • 36