我们有一个应用程序,它解析来自外部源的数据并将其本地化,并将图像保存和调整大小作为进程的最后一步。考虑到到目前为止我们处理的200万张图像的大小,我们一直在使用Rackspace文件托管数据.
require('/var/libs/rackspace/cloudfiles.php');
$auth = new CF_Authentication('xxx', 'yyyy');
$auth->authenticate();
$conn = new CF_Connection($auth,true);
$container = $conn->get_container('some container');
foreach ($lotsofitems as $onitem){
// check the record
// save the image to disk with cURL
// resize it into 4 more versions
// post it to rackspace
if(file_exists('/var/temp/'. $image_id . '_full'. $image_type)){
$object = $container->create_object($image_id . '_full' . $image_type);
$object->load_from_filename('/var/temp/'. $image_id . '_full' . $image_type);
unlink('/var/temp/'. $image_id . '_full' . $image_type); // remove the temp save
}
if(file_exists('/var/temp/'. $image_id . '_big'. $image_type)){
$object = $container->create_object($image_id . '_big' . $image_type);
$object->load_from_filename('/var/temp/'. $image_id . '_big' . $image_type);
unlink('/var/temp/'. $image_id . '_big' . $image_type); // remove the temp save
}
if(file_exists('/var/temp/'. $image_id . '_med'. $image_type)){
$object = $container->create_object($image_id . '_med' . $image_type);
$object->load_from_filename('/var/temp/'. $image_id . '_med' . $image_type);
unlink('/var/temp/'. $image_id . '_med' . $image_type); // remove the temp save
}
// delete the original
// repeat
}在优化解析器、GD等之后,我们已经对处理过程进行了基准测试,图像处理大约需要1秒,但是将5个图像变体传输到Rackspace需要花费2-5秒的时间,有时甚至会达到10+。
另外几点:
有没有人对大量传输到Rackspace有建议?在一定的持续时间/请求数量之后,我们是否应该重新连接?以其他方式优化我们的连接?或者仅仅是分叉进程和运行大量调用。
发布于 2012-07-16 20:48:00
你试过使用CloudFuse吗?它允许您将Rackspace CloudFiles桶挂载为挂载。
我用过这个,而且很不错--是他们为Rackspace设计的。
http://sandeepsidhu.wordpress.com/2011/03/07/mounting-cloud-files-using-cloudfuse-into-ubuntu-10-10-v2/
https://stackoverflow.com/questions/11423658
复制相似问题