search

Home  >  Q&A  >  body text

"Can an active PHP session cause a 504 error?"

My Nginx dedicated server has 4 CPU cores and 16GB of memory, the resources should be sufficient, but it crashes frequently (with a 504 error) due to limitations related to the CPU and PHP subprocesses.

I'm trying to find the reason. In WordPress, I have the following warning: A PHP session was created via the session_start() function call. This interferes with REST API and loopback requests. Before making any HTTP requests, the session should be closed via session_write_close().

Could this cause a 504 error?

P粉970736384P粉970736384453 days ago609

reply all(1)I'll reply

  • P粉738046172

    P粉7380461722023-09-09 19:55:25

    A REST API should be stateless. In this case, the session is of no use. It's hard to know for sure without more information. A 504 (timeout) error may occur if PHP starts a session in the background without proper configuration (e.g. Redis), where a custom session handler can store the session. use

    phpinfo();
    

    Find your PHP logs and other settings. Post here. You can also use the shell to view the configuration.

    php -i
    # 或者
    php -i | grep log
    # 或者
    php -i | grep session

    Please note that most systems run different PHP settings for cli and web requests. Use top or htop to view system tools that process results with high CPU and memory usage.

    reply
    0
  • Cancelreply