Well these couple days i spent a lot of my time debugging the nginx 504 gateway timeout error. As far as my understanding this error 504 caused by proxy timeout, or nginx wait too long for apche response. By the way i installed nginx as reverse proxy with Apache to server my static files. You can refer to my previous post: Install nginx as Reverse Proxy With Apache.
As i’m digging with Google, there are lot of possibilities of this problem. Some says because of fastcgi_read_timeout, but i’m not using fastcgi, the nginx server only serving static content. So i guess it’s not it. Then after i digging deeper, i found that my Apache causing high cpu load and memory used. Hmm… Wondering what cause this. This only happens when i post a new article in WordPress blog.
So my first guess is the Apache server still waiting for MySQL process to finish fetching the data, but it’s not finished. So the nginx keep waiting for Apache, and Apache waiting for MySQL. This process will keep loading while a new connection come, in the end it is deadlock!
Until now i’m still debugging the server, and still confuse. If you have ideas, please help me.