Ensuring user input isn't too large?

the handle_in callback called after the websocket transport decoding. And yes - the first argument for handle_in (the msg) is an elixir term, but it is a result of decoding byte-stream via Transport.decode!/2. So the size of packet of bytes should be checked there.

Or, better way as mentioned by @jmitchell - on cowboy level