Home  >  Article  >  Backend Development  >  【php】nginx PHP-FPM file_get_contents 超时失效

【php】nginx PHP-FPM file_get_contents 超时失效

WBOY
WBOYOriginal
2016-06-23 14:29:241324browse

 

我想来到这的同行们应开看过这篇文章,强烈推荐各位先阅读一下这篇文章,这篇文章中介绍的问题,基本同样的出现在我们的网站上,并一度使我们webserver负载升高(8核负载100)到不可用状态,导致前端502问题。

http://blog.s135.com/file_get_contents/ 

 

按照这篇文章中的讲述的方法:

1. file_get_contents 显式设置socket超时时间

 

经过测试是不可行的,进一步的测试,发现在php-fpm + nginx的系统环境中,这种设置超时的方式是不生效的。 而在其他环境中,如apache+php-cgi的方式,超时是可以生效的。

 

超时设置不生效的原因还不清楚,只是在我们的线上环境上是有问题的(nginx0.8 + php5.2 + php-fpm)

 

解决方法:

最后封装了一个curl库来解决这个问题

 

笔者对php-fpm的工作机理不是很清楚,也不知道自己描述的是否正确,本文完全是经验之谈,希望能帮到大家。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn