I am using node version v0.8.16. It bundles with openssl 1.0.0f and contains SSL_OP_NO_COMPRESSION and SSL_MODE_RELEASE_BUFFERS.
My test ssl server just echoes back hello world upon incoming https request and keep the connection open. From my test, the memory overhead per ssl connection is around 150k.
What is the approximate memory overhead for ssl connections in node ? how can I reduce ssl memory usage in this case ?
SSL needs per-connection space for:
- the socket FD
- about 16k for a receive buffer for the maximum possible SSL record, which varies slightly with the cipher suite
- an output buffer, probably also about 16k
- space to compute per-message MACs in
- handshake status, connection status, handshake MAC, etc.
- a pointer to the SSL session, which is shareable among connections to the same target, and which must contain the cipher suite, protocol, premaster secret, shared secret, session ID, peer certificate chain, timeout variables, ...
- whatever else I haven't thought of.
In addition the TCP connection will consume kernel space, e.g. for the socket send and receive buffers.
This recipe can be found in it's original form on Stack Over Flow.