I'm running PHP 5 on a shared VPS. I have a couple little apps that are using file_get_contents() and readfile() for various kinds of (what should be) low-overhead, fast outbound accesses ... that is, I'm handing URLencoded arguments to a couple fast servers and grabbing small patches of XML in return.
When I enter these URL+argument strings in a browser (with the caches turned off), I get effectively instant responses -- so the remote servers are working fine. But when I do the same thing via file_get_contents, the function works properly, but doesn't return data for about five long seconds (i.e., "one one-thousand, two one-thousand ... etc.).
Not that I can peer into the soul of my machine, but I get the impression that what's wrong here is something with function initialization or initial remote-site handshaking. Once data-transfer begins, it seems to occur at network rates. But I have no proof this is what's happening.
It must be a rare problem, because in searching around the wide world of PHP boards, I see no references at all to "file_get_contents being slow." Any idea what's happening here? Should I be doing something to set up a user agent around fopen_wrappers that speeds handshaking? Something odd about the PHP install?