Reputation: 1331
I currently have a docker image in a Lambda Function, using laravelphp/vapor:php82. I am returning a streamed response from OpenAI's API, back to the browser. On a normal server, this works fine. But when I deploy into AWS using Laravel Vapor, the response is buffered, even when I configure output_buffering to off and implicit_flush to on.
What must I do to disable output buffering?
Upvotes: 0
Views: 347
Reputation: 13
I suppose you have some kind of webserver redirecting traffic to your server into your codebase.
If you are using nginx i would try configuring fastcgi_buffering and proxy_buffering off on the specific URLs that are streaming content. So on one of my sites I configured /stream-response like
location ~ ^/stream-response {
fastcgi_buffering off;
fastcgi_request_buffering off;
proxy_buffering off;
proxy_cache off;
}
Make sure you add the correct setup to also direct the traffic to the codebase, you can probably find the location ~ .php$ block which will be setup to navigate to your index.php file.
If you are using Apache I would look into what might be buffering on its part. PHP-FPM can also buffer but nginx is able to configure it in the location block.
Never used AWS + Laravel Vapor but it's likely they configure a webserver on the server hosting your code.
Upvotes: 1