Skip to content

http.createServer highwatermark configΒ #32731

Closed

Description

@0807Jpatel

Is your feature request related to a problem? Please describe.
http.get allows you to set highwatermark values as of node 13.x. Both IncomingMessage and OutgoingMessage supports setting hwm values in config, those settings are also applied to socket. why can't we do the same for http.createServer
#30135

Describe the solution you'd like
set highwatermark and enable objectMode for response (writable).

Describe alternatives you've considered
Please describe alternative solutions or features you have considered.

Activity

  1. added
    feature requestIssues requesting new Node.js features.
    httpIssues and PRs related to the http subsystem.
    on Apr 9, 2020
  2. bnoordhuis commented on Apr 9, 2020

    @bnoordhuis
    Member

    set highwatermark and enable objectMode for response

    What would that do? It's not at all clear to me what use that has. Please elaborate.

  3. 0807Jpatel commented on Apr 9, 2020

    @0807Jpatel
    Author

    We are trying to generate backpressure over the network. we would like our highwatermark to be 5kb, but this is negated since response's highwatermark is always set to 16kb. we would like to be able to decrease it. so that it can generate back pressure faster.

    var server = http.createServer(function (request, response) {
      myReadable.pipe(response); //response's highwater marks is set to 16kb by default.
    });
  4. bnoordhuis commented on Apr 10, 2020

    @bnoordhuis
    Member

    Do I understand correctly you want to be able to override writableHighWaterMark like this?

    var server = http.createServer(function (request, response) {
      response.writableHighWaterMark = 5 * 1024;
      myReadable.pipe(response);
    });
  5. 0807Jpatel commented on Apr 10, 2020

    @0807Jpatel
    Author

    Yes that's exactly what we would like to do. But I don't think it's possible to overwrite writablehighwatermark after stream is created. So the simplest solution would be to implement at http.createServer level just like http.get

  6. added
    streamIssues and PRs related to Node.js streams.
    on Apr 10, 2020
  7. bnoordhuis commented on Apr 10, 2020

    @bnoordhuis
    Member

    It's read-only right now but that could probably be changed if there's a good enough use case. I've updated the labels.

    Having requests inherit it from the http.Server is both clunky and inflexible, IMO.

  8. 0807Jpatel commented on Apr 11, 2020

    @0807Jpatel
    Author

    @bnoordhuis how do we go about this? As far as I can tell both objectMode and highwatermark values for our stream are useless as long as we can't edit those values for response stream.

  9. bnoordhuis commented on Apr 12, 2020

    @bnoordhuis
    Member

    You can open a pull request with your suggested change. If you're not completely sure yet what direction to take, it's okay to open it in an incomplete state as a draft, to collect feedback.

    request

    You mentioned response in your original comment. Which one is it?

  10. 0807Jpatel commented on Apr 13, 2020

    @0807Jpatel
    Author

    response. yea that was a typo, and I will try to get a pull request, soon.

  11. ronag commented on May 15, 2020

    @ronag
    Member

    There are other way to create back pressure. You can pipe it through a transform stream that applies it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues requesting new Node.js features.httpIssues and PRs related to the http subsystem.streamIssues and PRs related to Node.js streams.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions