You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, a bit new to Erlang - is it possible to start, say, 3 outbound HTTP requests simultaneously, and collect the results from the caller (such that if each remote endpoint took ~2 seconds to reply, the total duration on the calling side would be ~2 seconds, and not 6)?
I've come across erpc.multicall and rpc.pmap in the stdlib, but I'm not sure either of those fit this use case, so curious if this would be something supported in the http client(s) out there themselves? (though search matches for "concurren" seem sparse).
I did see Elixir has a new Task.await_many() which seems similar (basically, JS Promise.all() equivalent).
Sorry for the slightly off topic question, but TIA if anyone can answer.
The text was updated successfully, but these errors were encountered:
Using HTTP/1.1, you can use Gun to do concurrent requests but you need to open 3 separate connections. This is because HTTP/1.1 is sequential. Browsers have used multiple connections for a long time because of that.
Using HTTP/2 (and, when it becomes available, HTTP/3), you can use a single Gun connection to do concurrent requests.
Gun is asynchronous so you can do the requests all at once and gather the results afterwards:
Your gather_results function (which could be your main receive function) can receive the responses asynchronously if necessary. The responses and data is sent as messages.
Hi, a bit new to Erlang - is it possible to start, say, 3 outbound HTTP requests simultaneously, and collect the results from the caller (such that if each remote endpoint took ~2 seconds to reply, the total duration on the calling side would be ~2 seconds, and not 6)?
I've come across erpc.multicall and rpc.pmap in the stdlib, but I'm not sure either of those fit this use case, so curious if this would be something supported in the http client(s) out there themselves? (though search matches for "concurren" seem sparse).
I did see Elixir has a new Task.await_many() which seems similar (basically, JS Promise.all() equivalent).
Sorry for the slightly off topic question, but TIA if anyone can answer.
The text was updated successfully, but these errors were encountered: