GIF上传的神秘问题? [英] Mystery issue with GIF upload?
问题描述
好的,所以每当我将此GIF上传到我的开发板(NGINX + PHP-FPM)时,我都会减速,直到最终504网关超时,好的,所以我知道您在想什么,继续修复这些nginx.conf和php-fpm设置",昨晚我将它们调整到了接近完美的水平,我的服务器现在运行出色.但是,一个特定的GIF仍然无法解决,将php-FPM运行到几乎100%(我的服务器上有顶级的四核处理器,我的服务器绝不是原始的.)
Alright, so whenever I upload this GIF to my board (NGINX+PHP-FPM) I get a slow down until an eventual 504 Gateway Time-out, alright, so I know what you're thinking, "go ahead and fix those nginx.conf and php-fpm settings", well I tweaked them to near perfection last night, my server is running brilliantly now. However, that one particular GIF still screws up, runs php-FPM to almost 100% (I have a great top of the line quad core processor in my server, my server is by no means primitive).
所以想知道它从何而来?我已经上传了10MB的GIF,尺寸比一个更大,以防万一(引起问题的那一个是600KB),并让服务器快速地对其进行了处理.
So want to know where it gets weirder? I've uploaded 10MB GIF's with bigger dimensions than the one in case (the one which is causing the issues is about 600KB) and had the server process them ridiculously quickly.
好的!因此,让我们进入日志,关于此问题,error_log不会输出任何信息.因此,我去了ahlead并在php-FPM配置中设置了一个慢日志.
Alright! So let's get into the log, error_log doesn't output anything in regards to this issue. So I went ahlead and set up a slowlog within the php-FPM config.
这是问题所在:
[02-Oct-2011 05:54:17] [pool www] pid 76004
script_filename = /usr/local/www/mydomain/post.php
[0x0000000805afc6d8] imagefill() /usr/local/www/mydomain/inc/post.php:159
[0x0000000805afb908] fastImageCopyResampled() /usr/local/www/mydomain/inc/post.php:107
[0x0000000805af4240] createThumbnail() /usr/local/www/mydomain/classes/upload.php:182
[0x0000000805aeb058] HandleUpload() /usr/local/www/mydomain/post.php:235
Here's the issue:
[02-Oct-2011 05:54:17] [pool www] pid 76004
script_filename = /usr/local/www/mydomain/post.php
[0x0000000805afc6d8] imagefill() /usr/local/www/mydomain/inc/post.php:159
[0x0000000805afb908] fastImageCopyResampled() /usr/local/www/mydomain/inc/post.php:107
[0x0000000805af4240] createThumbnail() /usr/local/www/mydomain/classes/upload.php:182
[0x0000000805aeb058] HandleUpload() /usr/local/www/mydomain/post.php:235
好的,让我们看一下post.php(粗体的159行):
if (preg_match("/png/", $system[0]) || preg_match("/gif/", $system[0])) {
$colorcount = imagecolorstotal($src_image);
if ($colorcount <= 256 && $colorcount != 0) {
imagetruecolortopalette($dst_image,true,$colorcount);
imagepalettecopy($dst_image,$src_image);
$transparentcolor = imagecolortransparent($src_image);
**imagefill($dst_image,0,0,$transparentcolor);**
imagecolortransparent($dst_image,$transparentcolor);
}
Okay, let's look at post.php (line 159 in bold):
if (preg_match("/png/", $system[0]) || preg_match("/gif/", $system[0])) {
$colorcount = imagecolorstotal($src_image);
if ($colorcount <= 256 && $colorcount != 0) {
imagetruecolortopalette($dst_image,true,$colorcount);
imagepalettecopy($dst_image,$src_image);
$transparentcolor = imagecolortransparent($src_image);
**imagefill($dst_image,0,0,$transparentcolor);**
imagecolortransparent($dst_image,$transparentcolor);
}
第107行:
fastImageCopyResampled($dst_img, $src_img, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y, $system);
Line 107:
fastImageCopyResampled($dst_img, $src_img, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y, $system);
upload.php,第182行(粗体):
**if (!createThumbnail($this->file_location, $this->file_thumb_location, KU_REPLYTHUMBWIDTH, KU_REPLYTHUMBHEIGHT))** { exitWithErrorPage(_gettext('Could not create thumbnail.'));
upload.php, line 182 (in bold):
**if (!createThumbnail($this->file_location, $this->file_thumb_location, KU_REPLYTHUMBWIDTH, KU_REPLYTHUMBHEIGHT))** { exitWithErrorPage(_gettext('Could not create thumbnail.'));
(请注意,该错误不会显示)
(note, that error does not show up)
另一个post.php(第235行):
$upload_class->HandleUpload();
The other post.php (line 235):
$upload_class->HandleUpload();
那我该怎么办?我怎样才能解决这个问题?我知道这是一个棘手的问题,但是如果你们能给我任何意见,将不胜感激.
So what can I do? How can I fix this? I know this is a tough issue, but if you guys could give me any input, it would be greatly appreciated.
哦,如果有人好奇,请使用以下GIF: http://i.imgur.com/rmvau.gif
Oh and in case anyone is curious, here's the GIF: http://i.imgur.com/rmvau.gif
推荐答案
您是否尝试过在nginx配置中设置client_body_buffer_size
指令?
Have you tried setting the client_body_buffer_size
directive in your nginx configs?
在此处查看更多信息: http://www.lifelinux .com/how-to-to-optimize-nginx-for-maximum-performance/
See more here: http://www.lifelinux.com/how-to-optimize-nginx-for-maximum-performance/
这篇关于GIF上传的神秘问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!