system/expressionengine/libraries/Core.php around line 64 (as of v2.9.0):
// Set a liberal script execution time limit, making it shorter for front-end requests than CI's default
if (function_exists("set_time_limit") == TRUE AND @ini_get("safe_mode") == 0)
@set_time_limit((REQ == 'CP') ? 300 : 90);
If you have a page that is taking more than 90 seconds to render, I would post a separate question about optimizing that template. ;)
set_time_limit() resets the counter from zero every time that it's called, so assuming you don't collide with Apache's timeout, you can add that to your script that is getting info about the files on the external server. Perhaps try to limit it to as small as possible; if the files are examined in a loop, place a reasonable timeout extension within the loop prior to each external call, e.g.:
Or whatever is actually needed for the communication to not be impeded between the two servers.