Worlize/WebSocket-Node — pull request #124 by simak-alexandr (2014-06-05 12:43:38+00:00)
Title: Permanent heavy load

Under permanent heavy load we experienced uncontrolled socket reading resulting in server crush (exceeding memory limit). Due to our specific, incoming data was huge in amount. Every tick server was just busy reading from incoming socket, .receiveBufferSize and .messageBlockingTime were not able to control the situation. Also, sometimes our processing of incoming messages could be completed at current tick, and sometimes it was not so.

The proposed changes allows to keep server running under extremely heavy load stable.

In case the incoming message can be processed at current tick nothing has to be changed in user code. In case there are few tick required - emitted event also contains 2nd and 3rd arguments as functions `pause` and `resume`. When it is necessary to wait for multiple operations to be completed - it is just safe to call `pause` several times one time per async operation and wait while all `resume` will alarm in operations callbacks.

Our current production uses node-0.8, the proposed fix was tested under 0.8 only. I guess, under node 0.10 the semantics of .nextTick changed, and probably .processFrame has to be rewritten with setImmediate to function properly.

Thanks for awesome library! :)