504 on AWS ec2 without executing long php script

I encountered an HTTP 504 timeout error for several times when I tried to call the GET API that was programmed by PHP.

Here is my server and AWS environment.

  • An ec2 exam with Amazon Linux that runs php code (5.4.40) with the apache server (2.4.12) to serve the api call from the client.
  • AWS elastic load platform for balancing traffic to one of my instances. (for now, I only have one instance, just install ELB for the future if I need more instances to handle traffic.)
  • AWS RDS Database (MySQL 5.6.21) for saving data.

From some articles about 504 gateway timeouts, I already tried to change these settings:

 # ELB
 idle timeout => 300

 # php.ini
 max_execution_time => 301
 max_input_time => 301

 # httpd conf
 MaxKeepAliveRequests => 100
 KeepAliveTimeout => 30

But all of them do not help me, he still gets a 504 gateway timeout.

php script script, mysql (AWS RDS) , , , .

, 504 , , , , 504, , - , , .

=== ===

PHP-, , .

2 php , , 2

:

My/Namespace
  - Class1.php
  - Class2.php

:

Class1

// Class1
namespace My\Namespace;
class Class1 {
    public static function getInstance() {
        //return...
    }
}

Class2

// Class2
namespace My\Namespace;
class Class2 {
    public static function getInstance() {
        //return...
    }

    public function getClass1Instance() {
        $class1 = Class1::getInstance();
        return $class1;
    }
}

Class2.php Class1, "use namespace", Class2.php

use My\Namespace\Class1;

! , " " Class2.php, Class1 Class2 , " " ?

p.s. , , 504, API , php

"Class1 Class2.php"

php

" Class2.php, getClass1Instance()"

, , , m (_ _) m

+4

All Articles