title: Processing data under load with GenServer (gen_server)
body: <p>I am testing the following pattern in a GenServer:</p>
  
  <pre><code>  def handle_info({:tcp, _, data}, s) do
      # IO.puts "\nrx: \n#{Base.encode16(data)}\n"
  
      extra = _proc_data(&lt;&lt;s.extra::binary, data::binary&gt;&gt;)
  
      :inet.setopts(s.socket, active: :once)
  
      {:noreply, %{s | extra: extra}}
    end
  </code></pre>
  
  <p>There is a problem when data comes in fast, and i'm unable to update state before  <code>:inet.setopts(s.socket, active: :once)</code> releases new data</p>
  
  <p>Must  <code>{:noreply, %{s | extra: extra}}</code> be the last line for <code>handle_info</code>, or can I perform the <code>:inet.setopts(s.socket, active: :once)</code> last?</p>
  
  <p>Is there a better way to do this?</p>