![](/img/trans.png)
[英]Rackspace cloud files: Image Upload to rackspace cloud files using PHP
[英]Optimizing Bulk Uploads to Rackspace Cloud Files via PHP
我们有一个应用程序可以解析来自外部源的数据并将其本地化,从而保存和调整图像的大小,这是该过程的最后一步。 考虑到我们处理的大小[到目前为止,已有200万张图片],我们一直在使用Rackspace Files托管数据...
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有建议吗? 经过一定时间/数量的请求后,我们应该重新连接吗? 通过其他方式优化我们的连接? 还是仅仅是分叉流程并运行大量呼叫。
您是否尝试过使用CloudFuse? 它允许您将Rackspace CloudFiles存储桶安装为安装。
我已经用过了,它非常好-使它适用于Rackspace的人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.