1

We have problem in our PHP application that runs in GCP Cloud run.

Environment: PHP 8 (nginx php-fpm) in docker - official image "php:8.1-fpm".

There are certain files that are failed to be sent to the client when client opens a page in our system. I am not able to reproduce the same behavior locally in docker (exactly the same image), so I guess this is Cloud run specific.

The file is served by this PHP code:

...
    header('Last-Modified: ' . $lmstring);
    header('Content-Lenght: ' . filesize($filename));
    readfile($filename);
    die;
}

Getting this warning from cloud run:

"Truncated response body. Usually implies that the request timed out or the application exited before the response was finished."

Info log from Google HTTPS load balancer (error code explained here):

statusDetails: "client_disconnected_after_partial_response"

Real example and some facts I already found out: Opening page X in the internal system. This page downloads Y other files - most of these Y files (css+js) are sent successfully, but some are truncated to ~3641 characters. All files that are sent incompletely are usually truncated to the same length (rarely a bit less). It's always the same files trucated and I didn't spot anything they have in common. Sometimes it is js file, sometimes it is css file. The response code is HTTP 200.

I didn't find any error in PHP error output - trying to turn errors on on all levels. We get errors from PHP normally in other cases, so I don't expect anything is silenced.

Anybody has any idea why might this be happening and how to deal with that?

scr4bble
  • 192
  • 1
  • 15

1 Answers1

2

Seems like I found the solution. Answer in following thread has helped: Google Cloud Run website timeouts when content length is between 4013-8092 characters. What is going on?

Try to explain the behavior is in the above thread too.

Turning the fastcgi bufferring off in nginx helped to get rid of the problem: fastcgi_buffering off; (nginx.conf)

scr4bble
  • 192
  • 1
  • 15