If one domain name resolves to the IP list, will the PHP function
file_get_contents() connect to the next IP if the first one is not available?
If the behavior of the function is consistent with the standard, then please refer to it.
No, it will not. Established experimentally.
adding multiple A records for the same name is an implementation of the simplest round-robin balancing mechanism. One of the drawbacks of which is that if one node is unavailable, the requests sent to it will not be executed and this will lead to partial unavailability of the resource. those. the algorithm is suitable for load balancing, but not for increasing availability. However, this does not mean that a specific client (php) cannot implement its own mechanism for bypassing alternative addresses.
The php documentation doesn't say anything about this. the documentation has a
gethostbynamel() function that returns a list, which means it can be implemented in php. I also found nothing in the RFC standards with a cursory search. I also looked in the C sources from php, but I could not find anything similar to the implementation of the workaround. since all this does not mean that it does not exist – I decided to do an experiment
added to one normal record two not normal ones (A 126.96.36.199 and A 188.8.131.52). Then I implemented a call to file_get_contents, after which I made sure that php version 7.0.15 perfectly receives content only for every 3rd request. If there was an option that changed this behavior, it would be described here …
I believe that the author of the question can implement his own function wrapper with the behavior he needs, using the IP addresses obtained from
gethostbynamel instead of the host,