Ensuring user input isn't too large?

I am using phoenix for websocket and http communication with clients.

Users can submit json messages which Phoenix converts to Elixir maps for me.

How can I easily and quickly check for and reject requests that are extremely large or complex so that the least amount of server cpu cycles and bandwidth are wasted?

My frontend http and web socket servers will need to forward the requests to backend processes on different nodes. So if a user floods large sized requests then bandwidth usage can cause congestion.