Using Elixir or Erlang as reverse proxy in front of other services?

I have a legacy over-coupled system (large!) that we are slowly breaking into a polyglot backend of cooperating services and I’m just exploring some options so this might be a dead end or not. Some parts of our app are great fits for elixir, and others we might leave alone (for now). In Python, one can split off parts from the main app with WSGI middleware, where the middleware almost acts like a proxy (I think plug is very similar in many respects). I’m wondering whether it might be feasible to do something similar for parts of the app across the two languages by having an Elixir layer act as the incoming request handler that either a) handles the whole thing and sends back the response or b) proxies on to the python app servers, which could take a while. So in case (b), the request connection could be open for a long time because we have some terrible db crap going on some of the time. I realize the proxying may add response time, but at the moment our response time is bad enough that this is likely the least of my worries. I expect that farming out what I can to Elixir will more than make up for this, though I would love to hear otherwise if I’m wrong.

Has anyone any experience with using either Elixir or Erlang apps in a similar pattern or with reverse proxying off them in general? Any tips or advice much appreciated.

I might be wrong, but I think going down the reverse-proxy-in-elixir path would require a non trivial amount of work that can be avoided – wouldn’t it be easier to have something like haproxy or aws load balancer do the proxying, and rewrite your pyhton app in elixir piece by piece? I worked with someone who was transitioning from ruby to elixir, and that was exactly what they did.

In the case you do decide to build this, maybe these projects and blog posts might help you

https://github.com/josevalim/proxy

https://blog.fourk.io/replace-your-production-api-with-elixir-today-4426a8903642

4 Likes