2017-06-19 40 views
0

我们有三台服务器运行我们的主站点。他们使用完全修补/更新的Window Server 2008 R2和MySQL 5.5。服务器在WordPress上的行为有所不同

第一台和第二台服务器没有问题。但是,第三台服务器(与第二台服务器在物理上相同,但网络有点不同 - 第二台服务器使用的是Meraki设备)存在问题。

我们实现了一个使用getimagesize()函数的自定义WordPress插件(通常在函数前使用@,但是我已经删除了这个以尝试查看错误)。我也禁用了Windows防火墙来覆盖我的基地。

在第三台服务器上,当加载WordPress后端时,它停在包含以下代码的函数中。日志显示没有特定的错误,并且页面错误只是超过了最大时间(目前是6分钟来测试此问题)。 php通过IIS7上的FastCGI运行。

任何有关可能导致这种情况的见解,将不胜感激!

这里是循环:

$doc = new DOMDocument; 
$internalErrors = libxml_use_internal_errors(true); 
$doc->loadHTML($contentNoReferences); 
libxml_use_internal_errors($internalErrors); 
$totalImages = 0; 

// Gather image data 
foreach($doc->getElementsByTagName('img') as $img) 
{ 
    $fileName = $img->getAttribute('src'); 

    $ignoreFileDimensions = true; 

    // Exclusion cases... CTAs, charts, infographics, graphs, and diagrams (treat _ as -) 
    $checkName = str_replace('_', '-', $fileName); 
    if(strpos($checkName, '-CTA-') === false && 
    strpos($checkName, '-CTA.') === false && 
    stripos($checkName, '-chart-') === false && 
    stripos($checkName, '-chart.') === false && 
    stripos($checkName, '-diagram-') === false && 
    stripos($checkName, '-diagram.') === false && 
    stripos($checkName, 'infograph') === false && 
    stripos($checkName, 'graph') === false) 
    { 
    $ignoreFileDimensions = false; 
    } 

    $totalImages++; 
    $lastSlash = strrpos(str_replace('\\', '/', $fileName), '/'); 
    $fileName = substr($fileName, $lastSlash + 1, strlen($fileName)); 

    $fileStats = getimagesize(get_option('siteurl') . '/../images/' . $fileName); 

    if($ignoreFileDimensions) 
    { 
    $fileStats[0] = -1; 
    $fileStats[1] = -1; 
    } 

    if($fileStats) 
    { 
    $images[] = array('filename' => $fileName, 'type' => $fileStats['mime'], 
    'width' => $fileStats[0], 'height' => $fileStats[1], 
    'size' => remote_file_size(get_option('siteurl') . '/../images/' . $fileName), 
    'class' => $img->getAttribute('class'), 
    'title' => $img->getAttribute('title'), 'alt' => $img->getAttribute('alt')); 
    } 
} 
+0

你确定'getimagesize'存在吗? – cwallenpoole

+0

@cwallenpoole感谢您的建议。我也考虑过这一点,并已经验证getimagesize是一个有效的功能。 – illmortem

+0

您能测量下载文件需要多少时间吗? ('$ fl = sys_get_temp_dir()。'/'。$ fileName; file_put_contents($ fl,file_get_contents(get_option('siteurl')。'/../images/'。$ fileName);') – cwallenpoole

回答

0

我已经找到了问题。

我们的CDN响应迅速,没有错误,但是当文件是本地的时候,它们之间有一些ip查找,每个文件都会在文件的访问中添加延迟。

最终导致超时。

相关问题