Nicolas

Nicolas

API call between two aps

Hi,

I’m building an app which I try to architecure as modular, inspired by microservices. The idea is to have one elixir appliciation for each bounded context. The question then is how to implement communication between application, like API calls.
I can implement a HTTP/JSON API facade for each service or I was thinking using clustering and call through application nodes. I guess this would require having GenServer for handling API calls.
Do you have any experience in such architectures and/or advices ?

Thanks.

Most Liked Switch mode

D4no0

D4no0

If you want to use OTP inter-node communication then this is as simple as using libcluster and erpc. There are few gotchas here and there so I would recommend to read the documentation very well if you plan on using it in production.

My only recommendation in this regard is to scale the application vertically as much as you can, since that will save you a great amount of trouble and OTP scales much better vertically than most of runtimes out there.

LostKobrakai

LostKobrakai

So pure curiosity?

Architectures like that can be done indeed, but I’d argue that one shouldn’t go there unless there’s a good operational reason for it. E.g. with recent interest in ML/AI in the community there’s a good reason to move that kind of work to a (small) set fo beefy machines with GPU, because having all webservers be such is expensive. This however is not a tool for domain or code organization.

lud

lud

You can adopt a modular desing inside a single OTP application. What problem are you trying to solve with microservices?

I guess this would require having GenServer for handling API calls.

If each app has a single GenServer process that does the calls to the other apps you are introducing a nasty bottleneck from the get go. I would not do that uless I have a specific reason to.

Last Post!

zachdaniel

zachdaniel

Creator of Ash

I think in order to advise on this kind of thing, I’d need to know why you want one elixir application per bounded context. And then I’d suggest inverting the question, and asking yourself what parts of your application needs the benefits that you’re looking for, and then apply the solution just to those parts.

For example:

I have an image processing pipeline that needs to be deployable independently so that it can be horizontally scaled independently. Therefore, I will create an application to manage the processes and state that are used to accomplish this.

I would not suggest choosing a design pattern for “all bounded contexts”. It may sound simpler, because you now have a one-to-one mapping between concepts (i.e bounded context == application), but it will also push you towards a place where you have a bunch of extra boundaries/state that serve no purpose.

So using the image processing example (and using Ash as frame of reference), I’d have all of my application logic in a single application(i.e shipped to all nodes of a cluster), but would have the resource(s) for processing an image call into some image processing service code, that perhaps runs only on certain nodes of the cluster, or on some other heterogenous nodes. That code would be just “regular elixir code”.

Where Next?

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
silverdr
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated! To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead. Sta...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
michallepicki
I am using Oban and occasionally, shortly after a deployment, a handful of jobs can fail because of dependency on other parts of the syst...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New

We're in Beta

About us Mission Statement