blinksocks / blinksocks

A framework for building composable proxy protocol stack.
Apache License 2.0
590 stars 79 forks source link

improve socket buffering strategy #87

Closed micooz closed 6 years ago

micooz commented 6 years ago

Socket.bufferSize is used to reduce memory grow, the current buffer size is hard coded to 1MB for each socket:

const MAX_BUFFERED_SIZE = 1024 * 1024; // 1MB

...

if (this._fsocket && this._fsocket.bufferSize >= MAX_BUFFERED_SIZE) {
  this._bsocket.pause();
}

The strategy is very simple, but we need to consider other connections as well.