-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ets table ibrowse_stream
grows endlessly
#157
Comments
No, you shouldn't have to clear out entries in the ETS table after each streaming request. Sounds like a bug - I will investigate. |
I ran a few different requests but couldn't reproduce this behaviour. Can you give me some more help in diagnosing this? What exactly are the options you are invoking ibrowse with? |
Thanks for checking that issue. I call opts = [headers: <...>, timeout: <...>, ibrowse: [max_sessions: 200, max_pipeline_size: 10, stream_to: {self(), :once}]
case HTTPotion.get(url, opts) do
%HTTPotion.AsyncResponse{id: id} ->
async_response(conn, id)
%HTTPotion.ErrorResponse{message: msg} ->
# log error
send_error_response(conn, 502, msg)
end
defp async_response(conn, id) do
:ok = :ibrowse.stream_next(id)
receive do
# here a lot of different cases, like matching :ibrowse_async_headers, :ibrowse_async_response_timeout, :connection_closed_no_retry and so on
{:ibrowse_async_response, ^id, data} ->
case chunk(conn, data) do
{:ok, conn} ->
async_response(conn, id)
{:error, reason} ->
conn
end
{:ibrowse_async_response_end, ^id} ->
# OUTPUT ETS TABLE SIZE
IO.inspect :ets.info(:ibrowse_stream, :memory) * :erlang.system_info(:wordsize)
conn
end
end And then I just run my elixir app locally and fire requests and see this
|
Any updates on this issue?, it seems related to a problem that i have, ibrowse is starting connections endlessly, ranch is killing the application, because it makes reach the limit of max acceptors |
I'm sorry I haven't had much time to look into this. Will try this week. |
Seems like this issue is easily solved by using I'll continue monitoring, but most likely this 'issue' is solved. Thanks again for your work! |
Arguably |
@gaynetdinov thank you for diligently following up on this. @sumerman good point, I'll try to add this functionality. That said, I'll happily accept a pull request too ;-) |
Is this still an issue? I have seen similar bevaviour in the past, but have not dug deeper into it and used a different client without streaming for now. I would love to go back though. |
Hello.
I have an API gateway elixir app, this app streams requests a lot. I've noticed that memory grows over time constantly and the main consumer is
ets
tables. The most of RAM got eaten byibrowse_stream
table (like 650 mb).So I put
IO.inspect :ets.info(:ibrowse_stream, :memory) * :erlang.system_info(:wordsize)
insidereceive
loop when the process receives:ibrowse_async_response_end
message. Turns out that the table is increasing after each streaming request.Is that some kind of expected behaviour? Should I remove pid id from ets manually after each streaming request like
:ets.delete(:ibrowse_stream, {:req_id_pid, id})
?Thanks.
The text was updated successfully, but these errors were encountered: