Erlang lib or System.cmd to other binaries for AWS?

At work we ran into the situation that Elixir AWS libraries are too limited/rough for our needs. There is an option to use erlang libraries (erlcloud is quite a good lib) or shell out to some other command line tool with System.cmd.

I have a feeling that native is better, but when confronted with the choice - I couldn’t really give any strong arguments why it’s better to use an erlang library with its inconveniences of charlists and a bit different style than Elixir, instead of cmd and parsing json.

Is there actually a benefit? Performance? Anything else?

1 Like

Spawning OS processes is way more expensive than calling local functions (even if the function spawn Erlang processes). Also it is much harder to end with zombie processes (which can be painful in poorly configured Docker containers) or any other issue with running external processes.


At work we built a load generator app in Elixir which uses erlcloud. We are sending 2m SNS messages with no issues (at some point you may notice that the HTTP connection pool becomes the bottleneck, but not the lib itself). Also, calls to erlcloud are wrapped in an Elixir module. Eg.: AWS.SNS.publish(topic, message), this in turn calls :erlcloud.

1 Like

Is it something you / your team built, right?

Yes. It is as simple as this:

defmodule AWS.SNS do
  def publish(topic, payload) do
    :erlcloud_sns.publish_to_topic(topic, Jason.encode!(payload))

Also it helps when unit testing because we can configure a different implementation or use a mock instead of this.