1

This question is for experienced architects - How do the big boys do it? :)

Overview

I am building this high traffic, analytics like solution based on .NET, it ultimately will hosted on Azure. Let's assume this web app will receive 500M+ "transactions" every day, and these are very quick hits to our servers, very little DB querying for each will be required, virtually all of the heavy lifting will be done on a server side on set intervals. I am pretty sure that I have to implement some sort of a queue that will store all of the incoming hits and implement "aggregators" on a back-end that will run every minute or so to process new items from the queue.

Suggested Solution

Correct me if I am wrong but I am thinking writing these transactions straight to the database (some sort of the log table) would be a mistake, so I will be utilizing the Azure Storage Account (Table) for my queue and spin off couple of Azure Worker Roles (based on need) to process the data and update the database. Thoughts?

It's important to remember that Azure Storage is mostly based on a per-transation model, so I would have to pay for all incoming transations (writes) AND for the transactions for my aggregators (reads). So 500M writes and 500M reads per day, which comes out to be around $100/day. Does that make sense? Also, with using Azure Storage can I read a block of rows (to account for a single transaction) or I would have to read the queue one record at the time?

Lastly, performing a DB insert/update for each row would be an overkill for my aggregators, so I am thinking each one should probably aggregate the workload in memory and then purge it to the database.

4

1 に答える 1

3

ストレージ内の分析データを更新するリクエストは、ライブ ユーザーに影響を与えることなくバックグラウンドでワーカー ロールがメッセージを処理できるように、キューにドロップされたメッセージを介して行う必要があることに同意します。AzureWatch @ http://www.paraleap.comなどを使用して、キュー内のデータ量に基づいてサーバーを自動的にスケーリングすることもできます。

各キューが 1 秒あたり最大 500 のトランザクションをサポートできるという事実について考えてみてください。さらに必要な場合は、複数のキューをホストし、キューにパターンを設定することを検討してください (「キュー 001..キュー 100」のようにランダムに接続できる X キューを使用するのと同じくらい簡単です。ワーカー ロールは 100 個のキューすべてをチェックしますが、 Web サーバーは 1 から 100 までの乱数を生成し、そのキューに接続します

トランザクションの量は実際にはもっと多いかもしれません: 1 日あたりのサービスへの 5 億ヒットは、おそらく次のことを意味します。

  • キューへの 5 億回の書き込み
  • キューからの 5 億回の読み取り
  • n * ストレージへの 500M の書き込み (n は倍数かもしれません。ストレージ構造が、書き出す前に最初に何かを読み取る必要があり、バッチ トランザクションが許可されている場合など)
  • x * 24*60*60/delay 新しいメッセージが存在するかどうかをキューに対してチェックします (x はキューの数、delay は各チェック間の秒単位の遅延)

ここで、キューを使用して書き込み/読み取りの量を最小限に抑えたい場合は、Web サーバーからの要求をキューにバッファリングして、すべてのデータ ポイントが個別のメッセージとして送信されるのではなく、まとめてバッチ処理することを検討してください。これにより、トランザクション (読み取りと書き込みの両方) としてもカウントされるキューへのヒットが制限されます。ヒットをキャプチャする Web サイトで静的変数を使用してロックを使用すると、すべてがメモリに保存され、ときどきキューにフラッシュされます。

テーブル ストレージに対するストレージ トランザクションの量を最小限に抑えたい場合は、可能であればローカル ストレージを使用してデータを事前に集約し、事前に集約されたデータのみをテーブル ストレージに同期することを検討してください。これは役立つかもしれません

データの書き込みをバッファリングするときは常に、何らかの理由でバッファリングされたデータを持つマシンに障害が発生し、バッファがまだフラッシュされていない場合、一部のデータが失われる可能性があると想定されています。ここでは金銭の取引を扱っていないため、データ損失に対する許容レベルは 0 よりもわずかに大きく、書き込みのバッファリングによるコスト削減はまれなデータ損失の可能性を相殺すると想定しています。

HTH

于 2013-02-11T21:02:41.663 に答える