0

外部ソースからのデータを解析してローカライズし、プロセスの最終ステップとして画像の保存とサイズ変更を行うアプリケーションがあります。処理のサイズ [現在までに 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 秒以上かかります。

  • 画像を取得: 1341964436
  • 取得した画像: 1341964436
  • リサイズされた画像: 1341964437
  • 曇った 1 つの画像: 1341964446
  • 曇った画像:1341964448
  • 画像で完成:1341964448

いくつかの追加ポイント:

  1. 当社の処理サーバーも Rackspace のクラウド上にあります。
  2. 約 30kb から 2kb の合計 5 つのイメージ バージョンがあります。
  3. すべての画像は転送前にディスクに保存され、転送後に削除されます
  4. 当社のコンテナ [全体的に複数使用していますが、アイテムごとに 1 つ使用しています] は CDN 対応です

Rackspace への一括転送に関する提案はありますか? 特定の期間/リクエスト数の後に再接続する必要がありますか? 他の方法で接続を最適化していますか? それとも、プロセスをフォークして多くの呼び出しを実行するだけですか。

4

1 に答える 1

1

CloudFuse を使ってみましたか? Rackspace CloudFiles バケットをマウントとしてマウントできます。

私はこれを使用しましたが、かなり良いです。Rackspace で機能するように作成した人です。

http://sandeepsidhu.wordpress.com/2011/03/07/mounting-cloud-files-using-cloudfuse-into-ubuntu-10-10-v2/

于 2012-07-16T20:48:00.293 に答える