-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Conversation
Currently when a TLS stream is paused the underlying socket is not paused. This results in a lot of data buffering within the OpenSSL context. This leads to two problems: firstly it destroys one of the advantages of streaming as excessive memory is used; secondly it doesn't provide push back to the client, so the client is unaware of the throttling, which is undesirable. This patch solves this by directly pausing (and resuming) the underlying socket.
This seems okay to me. Are you experiencing this data buffering? @mranney @dannycoates are you guys okay with this? |
Yeah I was seeing this in my test systems (may not end up being a problem on production I guess). I can try and generate an isolated test case if it is useful, but really it is just a case of doing req.pause(), wait some time req.resume() and you get flooded with a lot more data than just the socket buffer. (And if you poke around in the data structures you can call _internallyPendingBytes() to see that it is all buffered inside openssl data structures). |
We aren't doing pause on HTTPS right now, mostly because we don't use HTTPS for bulk transfers yet. This change sounds excellent though, because I'd like to start moving more things over HTTPS. |
There are two subclasses of However, I think that
Then, Also:
|
@bnoordhuis - On the master (not apply 815b672), the test (1fe318b) is very slow with libuv (similar to #1643 ?). with legacy:
with libuv:
|
@koichik - confirmed, will look into it. |
+1 isn't the performance difference likely related to libuv perf and not this change specifically. |
@koichik - libuv writes out much more data before the assertion is triggered:
So that's why it's taking 10x as long. libuv is holding up pretty well, it's pumping around 3x as much data per second as legacy. |
@bnoordhuis - Wow, it is great! |
815b672 has fixed #1643 (?) master (416c14f):
815b672:
|
confirmed! 815b672 looks good to me but I wish it had some comments. |
@koichik LGTM |
@ry - Thanks! |
@bennoleslie - Thanks for the report. Fixed a different way. |
@koichik - thanks for the fix, yours is much more elegant. I tried to fix it the way you did, but I couldn't get it working, so I'm glad you made a much better fix. |
Currently when a TLS stream is paused the underlying socket is not
paused. This results in a lot of data buffering within the OpenSSL
context.
This leads to two problems: firstly it destroys one of the
advantages of streaming as excessive memory is used; secondly it
doesn't provide push back to the client, so the client is unaware
of the throttling, which is undesirable.
This patch solves this by directly pausing (and resuming) the
underlying socket.