Will I miss anything important if I don't use Phoenix in this particular case?


As my first Elixir project, I’m developing a REST API. The service will be just a pricing engine. It will read about 15,000 products and its prices from a CSV file at start up. Then, it will just accept requests to calculate the subtotals and total associated with the products chosen by the multiple consumers of the service. That’s it. The actual ordering will be done by another system, and the “quotes” produced by the system do not need to be persisted. In case you’re wondering why even bother with a service, the rules to calculate the prices are sufficiently complex.

I haven’t decided if I’ll support both stateless and stateful operations, but even if I decide to support stateful operations, a GenServer will allow me to do that just fine.

On a second version of the service I might use ecto to do the initial load directly from the DB, but it’s definitely out-of-scope for the moment.

So, it seems to me, I can do this with just Elixir. Am I forgetting anything? I know if I decide to have the stateful operations that I’ll have to manage the session terminations manually. For example, a web client can disconnect and never reconnect. Still, that looks easy enough to do in Elixir. Does Phoenix help with that? Anything else?

Thanks in advance

You will miss websocket support, but if not needed, You might just use Cowboy, or Plug.

Yes, I’m planning on using Cowboy and Poison (or Jason) for the JSON encoding. I think those will be all my dependencies as even the CSV file I can read with just Stream.

On and no, there is no need for bi-directional communication as the prices won’t change while the system is running

1 Like

Cowboy will support the things you need from the web layer. It supports web-sockets out of the box too. Plug and phoenix add on this to make things more convenient (and perhaps easier to use in elixir?) but in this case I suggest you just go ahead and write the application as planned. If it works. All done.

If you find you need features which would be too hard to implement or become a maintenance burden using just cowboy (or other web server library) switching to plug or phoenix will be easy.


Thank you. Will do. I guess I needed some validation :grin:

1 Like

I would go with Plug or Raxx as there is not really a trade-off for choosing them, but you will avoid reimplementing common stuff like routing, and especially Plug has a bunch of community supported middleware. I don’t see a reason to interface with something like Cowboy unless you want to learn how the lower levels work.


Agree. I should have said :plug_cowboy which will pull both Plug and Cowboy

You can go metal, like in this post.

You have multiple solutions, and I like that with Elixir :slight_smile:

1 Like

Cool. That post is from one of two co-organizers of our Toronto Elixir Meetup, and we just had one this past Wednesday. I guess I can bug Tyler with questions if I get stuck :smile:

1 Like