How to communicate to a Elixir app from another Elixir app?

I have 2 long running Elixir applications. I have another phoenix application which acts like a dashboard for these 2 applications.

In the dashboard, I wanted to show the running status of these 2 applications. This is just to figure out all the components in the system are up and running.

From this dashboard, I also wanted to trigger some actions on these applications. To achieve this, I am thinking about doing the following:

  1. Each application exposes a HTTP API (planning to use plug)
  2. Dashboard does HTTP requests to these APIs and display the status accordingly
  3. This way, actions can also be triggered on the remote process.

There are many advantages for this design. This is simple to implement, the processes that the dashboard wants to monitor can be in separate machines, etc.

I am wondering, is this the best approach to follow. Or is there a different approach which can be followed.

Thanks

1 Like

If you put both applications in a single umbrella application then you won’t have to communicate over an HTTP API. You could just send erlang messages for communication.

1 Like

Thanks.

It is already in an umbrella project. If I understood you correctly, this what you are saying,

  1. There are 3 projects, A,B,dashboard
  2. A is started on machine1 with a node name a. This also starts a supervised process with a name registered globally status-handler.
  3. B is started on machine2 with a node name b. This also starts a supervised process with a name registered globally status-handler.
  4. Dashboard is started on machine3 with a node name dashboard
  5. When dashboard starts, it runs Node.connect to a and b to form the cluster
  6. Dashboard sends message to status-handler running on each connected node

Did I get that right?

Thanks for your help.

1 Like

that would be my go to. however as you mention each app is on a separate machine a http api would not be a bad idea. particularly if those services need to expose a http api to other clients anyway.

2 Likes