1

My PHP script runs okay when my traffic is 5000 visitor/ DAY - no error.

When I suddenly increase my traffic spent to 3000 visitor/ HOUR I get this many errors:

[26-May-2017 07:30:03 Asia/Jakarta] PHP Warning: file_get_contents(http://mydomain1.com/api/ip2country_v6/?ip=76.119.xxx.xxx): failed to open stream: HTTP request failed! in /home/h32xxx/mydomain2.com/landings/script.php on line 47

  • This php script is in my mydomain2.com
  • file_get_contents is requesting from mydomain1.com

My mydomain2.com and mydomain1.com is on 1 server account. I can't do 'http://localhost/~h32xxx/api/ip2country_v6/?ip=76.119.xxx.xxx' because my CPanel settings block it (mod_userdir is disabled)

What is the problem and how do I fix it?

Frits
  • 7,341
  • 10
  • 42
  • 60
folazozi
  • 11
  • 1
  • Without knowing if the other file gets called at all and returns a 500 code/times out etc, that's impossible to say. Is there any relevant logs on the other domain? – Kevin Sijbers May 26 '17 at 04:30
  • Strange. That is no error on the other domain. Maybe its because the dns resolving is too much? I set my server dns resolve thru google dns 8.8.8.8 and 8.8.4.4 – folazozi May 26 '17 at 04:37
  • DNS records should be cached, so that shouldn't be the issue. Your server is probably not set up to allow for many simultaneous connections. (See this for a pretty decent explanation: https://stackoverflow.com/questions/3389496/how-do-you-increase-the-max-number-of-concurrent-connections-in-apache). – Kevin Sijbers May 26 '17 at 04:42
  • A good change, assuming most of your requests will be from the same user multiple times, would be to somehow cache the results of that API call. it looks like the range of substantially different calls is manageable – Kevin Sijbers May 26 '17 at 04:44

0 Answers0