How to use this erlang package? (Buoy)

erlang
troubleshooting

#1

I’m trying to use buoy but there are some weird things I’m encountering. I feel like looking at the source code may answer it, but I don’t know erlang so it’s quite confusing.

Here’s my code:

url = "https://httpbin.org/get"
buoy_url = url |> :buoy_utils.parse_url

pool = :buoy_pool.start(buoy_url, [backlog_size: 1024, pool_size: 16])
IO.inspect pool

:buoy.get(buoy_url)

This appears to work

Question 1: But, I want to set the timeout, as well as some headers. According to the docs it says I do this:

:buoy.get(buoy_url, %{timeout: 500})

but when I do this, it “hangs”… almost like its frozen. Did I format the erlang map wrong? I googled and it seems right?

Question 2: the version on hex is a little outdated. When I try doing this:

  {:buoy, "~> 0.1", git: "https://github.com/lpgauth/buoy.git"},

it says:

Dependencies have diverged:
* metal (https://github.com/lpgauth/metal.git)
  different specs were given for the metal app:

  > In deps/shackle/rebar.config:
    {:metal, ~r/.*/, [env: :prod, override: true, git: "https://github.com/lpgauth/metal.git", tag: "0.1.1", manager: :rebar3]}

  > In deps/foil/rebar.config:
    {:metal, "0.1.1", [env: :prod, repo: "hexpm", hex: "metal", override: true, manager: :rebar3]}

  Ensure they match or specify one of the above in your deps and set "override: true"
** (Mix) Can't continue due to errors on dependencies

Question 3: One thing I find weird is that you have to start the pool based on URL… in my use case I don’t know the URL beforehand. Do you think its crazy to attempt to start a new pool for every URL, and just let it fail with {:error, :pool_already_started} if it’s already started? I’m not quite sure the overhead of starting a new pool…


#2

I got some help on IRC for these questions

Question 2:

  {:buoy, git: "https://github.com/lpgauth/buoy"},
  {:metal, "~> 0.1", [override: true, manager: :rebar3]},

Question 1: solved by qeustion 2

Question 3: instead of checking every time for the pool just assume its connected and then fallback to :pool_not_started (which happens way less frequently)


#3

Thanks for reporting back! Out of curiosity is there something in particular that attracted you to buoy over other HTTP libraries like Httpoison, Httpotion, or Tesla?


#4

I need to do 25,000 requests per second, and a lot more than that as well.

I’m currently using machine gun and its maxing out 100% cpu at only 400 RPS, so Im trying different options


#5

Ah, that makes sense. I’m curious to know what library you end up with.