egze

egze

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?

Most Liked

hauleth

hauleth

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.

vrcca

vrcca

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))
  end
end

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

vrcca

vrcca

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.

Where Next?

Popular in Discussions Top

sashaafm
I’m trying to evaluate the best combo/stack for a BEAM Web app. Right now I’m exploring Yaws a bit, after having dealt with Phoenix for a...
New
arcanemachine
https://nitter.net/josevalim/status/1744395345872683471 https://twitter.com/josevalim/status/1744395345872683471
New
lucaong
Hello Elixir and Nerves community, I have been working for a while on an open-source embedded key-value database for Elixir, that I call...
230 13924 124
New
New
IVR
Hi all, I’ve seen a number of related threads in the past, but I’d still be very curious to hear an up-to-date opinion on this topic. I...
New
sashaafm
Piggy backing a bit on @dvcrn topic BEAM optimization for functions with static return type?, I’ve been trying to understand in a deeper ...
New
New
AstonJ
I’ve just started the Phoenix part of the utterly brilliant online course by @pragdave. On generating the Phoenix app he uses the --no-ec...
New
cblavier
Hey there, It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
New
scouten
I’m looking for a host for the server part of a small (personal) side project that I’m working on. It’s currently written in Node.js and ...
New

Other popular topics Top

sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 42920 311
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 29377 241
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

We're in Beta

About us Mission Statement