Closed jwazne closed 5 years ago
It's hard to say without a reproducible example. Can you somehow make a simple project which demonstrates the problem? If yes, we'd be happy to debug.
Without an example, and based on your description, my first hunch is that a netsplit occurs because of long deserialization time on the Phoenix side. At our company, we actually have a similar use case to yours. We occasionally send some large messages, and originally we used a custom JSON/gzip serializer. At some point we noticed various problems with very large messages, though I can't recall if the symptom was exactly the same as yours.
Our solution boiled down to two things:
:erlang.term_to_binary
and :erlang.binary_to_term
The thing is that on the Phoenix side, messages are deserialized in the socket process, so long deserializations of large messages block the entire communication, which might provoke a netsplit.
With our new approach, compression/decompression is not done in the socket process, which vastly reduced the decoding time in the socket process.
Since the payload is compressed, we went a step further and switched the serializer to be based on :erlang.term_to_binary
and :erlang.binary_to_term
, which work pretty fast, even for larger payloads.
So on the Phoenix side, a message processing now goes as follows:
:binary_to_term
).We actually went a step further, and uncompressed the message in a separate GenServer. We did this to keep the channel responsive to other messages.
With those changes, we were able to significantly reduce processing time in the socket process, and in the channel process. As a result, these processes were much more responsive.
I'm not sure if this would fix your problems, but you could give it a try.
Hello,
First of all I'd like to say good job for this client, we are using it to communicate between Phoenix apps.
All is working fine but we are now facing performance issues...
Context
Environment
Broker app:
Client app:
Problem
When sending multiple messages over the channel, using for example a loop or Enum.each, only few messages manage to get to the broker channel handle_in function. Then the client crash with the following error: