Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[💡FEATURE REQUEST]: Streaming request [WIP] & responses [HTTP-DONE] #923

Open
1 of 4 tasks
lwc opened this issue Jan 30, 2018 · 31 comments
Open
1 of 4 tasks

[💡FEATURE REQUEST]: Streaming request [WIP] & responses [HTTP-DONE] #923

lwc opened this issue Jan 30, 2018 · 31 comments
Assignees
Labels
C-enhancement Category: enhancement. Meaning improvements of current module, transport, etc.. P-GRPC Plugins: GRPC P-HTTP Plugin: HTTP P-jobs Plugin: Jobs S-RFC Request: Request for comments Y-high Priority: High

Comments

@lwc
Copy link

lwc commented Jan 30, 2018

This project looks like it could be very useful in building a GRPC server bridge for PHP, which would be amazing.

GRPC has the concept of streaming request & responses, is that something you'd consider adding to roadrunner/goridge?

Thanks


This ticket (since most of the users know it) split into the four parts:

  • HTTP response streaming [done in v2023.3]
  • HTTP request streaming
  • gRPC response streaming
  • gRPC request streaming
@wolfy-j
Copy link
Contributor

wolfy-j commented Jan 30, 2018

It can be done by locking done and working with one worker within the request. This is definitely something we are going to consider adding going forward.

@wolfy-j
Copy link
Contributor

wolfy-j commented Jun 13, 2018

I have put a foundation for streaming responses into a newer version. Streaming requests will be looked at once this feature it complete. See #9

@wolfy-j
Copy link
Contributor

wolfy-j commented May 2, 2019

This will be coming in a separate server due async mode of underlying workers.

@wolfy-j wolfy-j closed this as completed May 2, 2019
@wolfy-j wolfy-j reopened this Jun 1, 2019
@pwilsoncentre
Copy link

I would love to see streaming support as well, but for large HTTP responses. I noticed this issue was reopened a few days ago, so does that mean that some progress will be made here? If I had time to learn Go I'd offer to help, but as it is, I can only offer my encouragement - this would be a really cool feature to have.

@wolfy-j
Copy link
Contributor

wolfy-j commented Jun 4, 2019

Yes, this issue will be reconsidered for 1.5.0. No timeline yet but there are some initial experiments already made.

@wolfy-j
Copy link
Contributor

wolfy-j commented Oct 12, 2019

Not in 1.5.0. We are working on a protocol update (with few extra features and perf improvements), so most likely it will be 2.0.0.

@rustatian rustatian changed the title Request: Streaming request & responses [RFC] Streaming request & responses Mar 14, 2020
@Ocramius
Copy link

Ha, this is quite a roadblock: I was trying to migrate an existing system to RR this weekend, and one of the payloads that we stream is a GIGANTIC XML Sitemap that needs to be produced chunk-by-chunk (especially important to avoid running into memory limits).

I'm unsure about whether this is to be done in the GO components, or in the PHP-side of things (PSR-7 stream response missing there too, perhaps?).

I haven't done a detailed analysis, but this is indeed the biggest limitation I faced so far with the tool, whereas everything else is, I must say, quite impressive :-)

@wolfy-j
Copy link
Contributor

wolfy-j commented Apr 10, 2021

With RR2 refactor we might be able to take a look at this issue with a fresh approach. We will discuss this internally to see if it is possible.

@rustatian rustatian self-assigned this Apr 10, 2021
@rustatian
Copy link
Member

Discussion: Local pipelining with jobs + broadcast plugin

@wolfy-j
Copy link
Contributor

wolfy-j commented May 21, 2021

Essentially we have an idea of how to solve this issue with:

  1. No memory leaks
  2. No blocking on HTTP worker
  3. Proper load balancing and prevention of over saturation
  4. Side effect - extra feature reliable long polling in PHP
  5. Horizontal scalability

@wolfy-j
Copy link
Contributor

wolfy-j commented May 21, 2021

@rustatian we should consider doing the same for GRPC (streaming).

@rustatian rustatian transferred this issue from roadrunner-server/roadrunner Sep 18, 2021
@rustatian
Copy link
Member

A little update about streaming file responses. The sendfile HTTP middleware handles the X-Sendfile header and streams the response back w/o involving the worker in the process. So, you are able to handle the requests with the PHP worker and stream the file(s) in parallel. More info here: roadrunner-server/roadrunner-plugins#9, PR roadrunner-server/roadrunner-plugins#56.

@Ocramius
Copy link

@rustatian streaming files usually not the problem though: streaming batches (think "massive CSV generated from DB") is still the issue though

@rustatian
Copy link
Member

@rustatian streaming files usually not the problem though: streaming batches (think "massive CSV generated from DB") is still the issue though

Yep, sure. That's was just a little update about streaming in general. Not about the ticket's topic.

@rustatian rustatian changed the title Dec 25, 2021
@rustatian rustatian transferred this issue from roadrunner-server/roadrunner-plugins Jan 16, 2022
@rustatian rustatian added C-enhancement Category: enhancement. Meaning improvements of current module, transport, etc.. P-GRPC Plugins: GRPC P-jobs Plugin: Jobs P-HTTP Plugin: HTTP S-RFC Request: Request for comments and removed P-jobs Plugin: Jobs labels Jan 16, 2022
@WagnerPMC
Copy link

+1
It would be nice to see a ready implementation of this feature request

@rustatian rustatian added the Y-high Priority: High label May 14, 2022
@rustatian rustatian modified the milestones: v2.10.0, v2.11.0 May 17, 2022
@rustatian rustatian removed this from the v2.11.0 milestone Aug 11, 2022
@rustatian rustatian added this to the v2.13.0 milestone Nov 11, 2022
@rustatian
Copy link
Member

Hey, community 👋🏻
Response streaming will be in the v2.13.0 version by default (supported by both, RR and PHP workers).

@tux-rampage
Copy link

tux-rampage commented Dec 8, 2022

Thanks for all the effort you guys are putting into this.

How should this work? Can the php worker delegate the response sending to another process (maybe a php job, a go service, nodejs service, etc...) which will then stream the response and complete the request via roadrunners RPC or am I on the wrong track?

Could you briefly outline how this should work?

@rustatian
Copy link
Member

Yeah, sure.

  1. We have two plugins that would support this feature -> http and gRPC.

For the http plugin, we will support the response streaming. We did this previously in the v2.10, but I decided to not include that because of some known bugs which may affect the users.

For the gRPC plugin, both response and request streaming would be supported. So basically, that would block the worker during the stream, but you would have the ability to stream some big payloads from some external system, for example, and handle it via your PHP worker.

Before the release, I'll release the usual beta-rc binaries, so, anyone might test that and put the feedback here. So, I would be able to tune this feature before the release.

I can't explain how this would work from the PHP side 😭, you may ask our PHP team in the Discord 😃

@Matt-Woz
Copy link

Matt-Woz commented Jun 5, 2023

Hi, are there any updates on how this is going? Do we have an ETA on when this might be released? Thanks

@rustatian
Copy link
Member

Hey @Matt-Woz 👋🏻
PHP worker and php-goridge transport have recently been updated to support response streaming. RR (Golang) part is planned for the v2023.3.0.

@rustatian rustatian added this to the v2023.3.0 milestone Jun 5, 2023
@rustatian rustatian changed the title [💡FEATURE REQUEST]: Streaming request & responses [💡FEATURE REQUEST]: Streaming request [WIP] & responses [DONE] Oct 7, 2023
@rustatian rustatian changed the title [💡FEATURE REQUEST]: Streaming request [WIP] & responses [DONE] [💡FEATURE REQUEST]: Streaming request [WIP] & responses [HTTP-DONE] Oct 7, 2023
@rustatian rustatian modified the milestones: v2023.3.0, v2024 Oct 7, 2023
@FluffyDiscord
Copy link

Would it be possible to add also the HTTP request streaming after the move of internal communication from JSON to protobuf? It would make big file uploads extremely simple to do, instead of the current approach of sending small chunks. (Is there currently a better way?)

@rustatian
Copy link
Member

@FluffyDiscord Sure 😃 If someone willing to help me (with the PHP part) with that, I'm all ears 👂 Since I'm not a PHP dev at all.

@FluffyDiscord
Copy link

I think RR could create and pass to PHP a port (assuming locally running RR and PHP app) or TCP endpoint alongside the normal request. We could then read from the opened socket. Basically RR would be just a passthrough. Then whenever PHP returns a response the stream would close.

I am completely new in communication using a sockets, but I think this is the only way. Saving the request as temp file (not talking about sockets) would be probably an option too, but I would like to not use file buffering.

This might be more of a question to the Spiral team, which are experienced with this kind of stuff I imagine.

@L3tum
Copy link

L3tum commented Feb 26, 2024

I don't think that's even necessary. I'm not sure how protobuf comms work, but since the worker comms are running in a goroutine in RR, blocking on sending the request shouldn't pose a problem, so in PHP we simply would need to signal that the request is ongoing. Thinking about it, RR could enable it by sending a request in 2-3 frames (signal for stream + request line, headers, body), with the second/third frame only after it was requested by the PHP side. In return the PHP side would not need much change. Nyholm's PSR7 request object already supports a lazily loaded body, so there should be minimal change necessary (most likely the framework integrations would need to add support for wrapping the RPC request for the request body in some manner for the framework). I'm not sure what work would need to be done in Go though, since I don't exactly know if it's waiting for the full request right now or already streams it internally. But if you need some support for this @rustatian hit me up (after the async + circuitbreaker stuff 😆 ) :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: enhancement. Meaning improvements of current module, transport, etc.. P-GRPC Plugins: GRPC P-HTTP Plugin: HTTP P-jobs Plugin: Jobs S-RFC Request: Request for comments Y-high Priority: High
Projects
Status: 🏗 In progress
Development

No branches or pull requests

10 participants