クラウド設計パターンCloud Design Patterns

これらの設計パターンは、信頼性の高い、スケーラブルで安全なアプリケーションをクラウドに構築するために役立ちます。These design patterns are useful for building reliable, scalable, secure applications in the cloud.

パターンごとに、そのパターンで対処する問題、パターンの適用に関する考慮事項、Microsoft Azure に基づいた例を説明します。Each pattern describes the problem that the pattern addresses, considerations for applying the pattern, and an example based on Microsoft Azure. ほとんどのパターンには、Azure でのパターンの実装方法を示すコード サンプルまたはスニペットが含まれています。Most of the patterns include code samples or snippets that show how to implement the pattern on Azure. ただし、パターンのほとんどは、ホストが Azure か他のクラウド プラットフォームかにかかわらず、分散システムに関連しています。However, most of the patterns are relevant to any distributed system, whether hosted on Azure or on other cloud platforms.

クラウド開発での課題Challenges in cloud development

Availability

可用性Availability

可用性とは、システムが機能し動作している時間の割合です。通常は稼働時間の比率として計測されます。Availability is the proportion of time that the system is functional and working, usually measured as a percentage of uptime. システム エラー、インフラストラクチャの問題、悪意ある攻撃、およびシステムの負荷によって影響を受けることがあります。It can be affected by system errors, infrastructure problems, malicious attacks, and system load. クラウド アプリケーションは通常はサービス レベル アグリーメント (SLA) をユーザーに提供するため、アプリケーションの可用性が最大限になるように設計する必要があります。Cloud applications typically provide users with a service level agreement (SLA), so applications must be designed to maximize availability.

Data Management

データ管理Data Management

データ管理はクラウド アプリケーションの重要な要素であり、品質属性のほとんどに影響します。Data management is the key element of cloud applications, and influences most of the quality attributes. 通常、パフォーマンス、スケーラビリティ、または可用性の理由から、データは複数のサーバーにまたがってさまざまな場所でホストされます。これによって、広範な課題が生じることがあります。Data is typically hosted in different locations and across multiple servers for reasons such as performance, scalability or availability, and this can present a range of challenges. たとえば、データの整合性を維持する必要があります。また、通常はさまざまな場所にあるデータを同期する必要があります。For example, data consistency must be maintained, and data will typically need to be synchronized across different locations.

Design and Implementation

設計と実装Design and Implementation

優れた設計に含まれる要素には、コンポーネントの設計およびデプロイの一貫性や統一性、管理および開発を容易にする保全性、コンポーネントやサブシステムを他のアプリケーションやシナリオで利用できる再使用可能性などがあります。Good design encompasses factors such as consistency and coherence in component design and deployment, maintainability to simplify administration and development, and reusability to allow components and subsystems to be used in other applications and in other scenarios. 設計および実装フェーズで行われる意思決定は、クラウドでホストされているアプリケーションやサービスの品質と総保有コストに大きな影響を及ぼします。Decisions made during the design and implementation phase have a huge impact on the quality and the total cost of ownership of cloud hosted applications and services.

Messaging

メッセージングMessaging

クラウド アプリケーションの分散特性には、スケーラビリティを最大化するために、コンポーネントとサービスが (できれば疎結合的に) 接続されているメッセージング インフラストラクチャが必要です。The distributed nature of cloud applications requires a messaging infrastructure that connects the components and services, ideally in a loosely coupled manner in order to maximize scalability. 非同期メッセージングは広く使用されており、多数の利点がありますが、メッセージの順序付け、有害メッセージ管理、べき等性などの課題もあります。Asynchronous messaging is widely used, and provides many benefits, but also brings challenges such as the ordering of messages, poison message management, idempotency, and more

Management and Monitoring

管理と監視Management and Monitoring

クラウド アプリケーションはリモート データ センターで実行するため、インフラストラクチャまたは場合によってはオペレーティング システムを完全に制御することはできません。Cloud applications run in in a remote datacenter where you do not have full control of the infrastructure or, in some cases, the operating system. このため、オンプレミス デプロイよりも管理と監視は難しくなります。This can make management and monitoring more difficult than an on-premises deployment. アプリケーションはランタイム情報を公開する必要があります。管理者とオペレーターはこれを使用してシステムの管理と監視を行うことができます。また、この情報に基づいて、アプリケーションの停止や再デプロイを行わずに、変化するビジネス要件やカスタマイズに対応することができます。Applications must expose runtime information that administrators and operators can use to manage and monitor the system, as well as supporting changing business requirements and customization without requiring the application to be stopped or redeployed.

Performance and Scalability

パフォーマンスとスケーラビリティPerformance and Scalability

パフォーマンスは、システムが一定時間内にアクションを実行する応答性を示します。一方、スケーラビリティとは、システムがパフォーマンスに影響せずに負荷の上昇を処理できる能力、あるいは使用可能なリソースをすぐに増加できる能力です。Performance is an indication of the responsiveness of a system to execute any action within a given time interval, while scalability is ability of a system either to handle increases in load without impact on performance or for the available resources to be readily increased. 通常、クラウド アプリケーションが直面するワークロードやアクティビティのピークは変動しています。Cloud applications typically encounter variable workloads and peaks in activity. これらを予測することは、特にマルチテナント シナリオではほとんど不可能です。Predicting these, especially in a multi-tenant scenario, is almost impossible. 代わりに、アプリケーションは、要求のピークに対応できるように制限範囲内でスケールアウトし、要求が減少するとスケールインできることが必要です。Instead, applications should be able to scale out within limits to meet peaks in demand, and scale in when demand decreases. スケーラビリティは、コンピューティング インスタンスだけではなく、データ ストレージやメッセージング インフラストラクチャなど他の要素にとっても重要です。Scalability concerns not just compute instances, but other elements such as data storage, messaging infrastructure, and more.

Resiliency

回復性Resiliency

回復性とは、障害を正常に処理して復旧するシステムの機能です。Resiliency is the ability of a system to gracefully handle and recover from failures. クラウド ホスティングには、マルチテナントのアプリケーションが多い、共有プラットフォームを使用する、リソースと帯域幅を競合する、インターネットで通信する、コモディティ ハードウェア上で実行する、という特性があります。この特性は、一時的な障害と永続的な障害の両方が発生しやすくなることを意味します。The nature of cloud hosting, where applications are often multi-tenant, use shared platform services, compete for resources and bandwidth, communicate over the Internet, and run on commodity hardware means there is an increased likelihood that both transient and more permanent faults will arise. 迅速かつ効率的に障害を検出して復旧することが、回復性を維持する上で重要となっています。Detecting failures, and recovering quickly and efficiently, is necessary to maintain resiliency.

Security

セキュリティSecurity

セキュリティとは、設計された用途以外の悪意あるアクションや偶発的なアクションを防ぎ、情報の漏えいや損失を防ぐシステムの機能です。Security is the capability of a system to prevent malicious or accidental actions outside of the designed usage, and to prevent disclosure or loss of information. クラウド アプリケーションは、信頼できるオンプレミス境界の外側でインターネット上に存在します。一般に公開されていることも多く、信頼できないユーザーが利用する場合もあります。Cloud applications are exposed on the Internet outside trusted on-premises boundaries, are often open to the public, and may serve untrusted users. アプリケーションの設計とデプロイでは、悪意のある攻撃から保護し、承認したユーザーのみにアクセスを制限し、機密データを保護する必要があります。Applications must be designed and deployed in a way that protects them from malicious attacks, restricts access to only approved users, and protects sensitive data.

パターンのカタログCatalog of patterns

パターンPattern まとめSummary
AmbassadorAmbassador コンシューマー サービスまたはアプリケーションの代わりにネットワーク要求を送信するヘルパー サービスを作成します。Create helper services that send network requests on behalf of a consumer service or application.
破損対策レイヤーAnti-Corruption Layer 最新のアプリケーションとレガシ システムの間にファサードすなわちアダプター レイヤーを実装します。Implement a façade or adapter layer between a modern application and a legacy system.
フロントエンド用バックエンドBackends for Frontends 特定のフロント エンド アプリケーションやインターフェイスによって使用される個別のバックエンド サービスを作成します。Create separate backend services to be consumed by specific frontend applications or interfaces.
バルクヘッドBulkhead アプリケーションの要素をプールに分離し、1 つの要素が失敗しても、他の要素が引き続き機能できるようにします。Isolate elements of an application into pools so that if one fails, the others will continue to function.
キャッシュアサイドCache-Aside オンデマンドでデータをデータ ストアからキャッシュに読み込みます。Load data on demand into a cache from a data store
サーキット ブレーカーCircuit Breaker リモート サービスまたはリソースとの接続時の修正に要する時間が一定しないエラーを処理します。Handle faults that might take a variable amount of time to fix when connecting to a remote service or resource.
CQRSCQRS 個別のインターフェイスを使用して、データを更新する操作とデータを読み取る操作を分離します。Segregate operations that read data from operations that update data by using separate interfaces.
トランザクション補正Compensating Transaction 一連のステップ (最終的に一貫性のある操作を形成する) で実行された作業を元に戻します。Undo the work performed by a series of steps, which together define an eventually consistent operation.
競合コンシューマーCompeting Consumers 複数の同時実行コンシューマーが、同じメッセージング チャネルで受信したメッセージを処理できるようにします。Enable multiple concurrent consumers to process messages received on the same messaging channel.
コンピューティング リソース統合Compute Resource Consolidation 複数のタスクまたは操作を 1 つのコンピューティング単位に統合します。Consolidate multiple tasks or operations into a single computational unit
イベント ソーシングEvent Sourcing 追加専用ストアを使用して、ドメイン内のデータに実行されるアクションを記述する一連のイベントすべてを記録します。Use an append-only store to record the full series of events that describe actions taken on data in a domain.
外部構成ストアExternal Configuration Store アプリケーション展開パッケージから、一元管理される場所に構成情報を移動します。Move configuration information out of the application deployment package to a centralized location.
フェデレーション IDFederated Identity 外部の ID プロバイダーに認証を委任します。Delegate authentication to an external identity provider.
ゲートキーパーGatekeeper 専用のホスト インスタンスを使用して、アプリケーションとサービスを保護します。このホストインスタンスは、クライアントとアプリケーションまたはサービスの間でブローカーとして機能し、要求を検証して不適切な部分を除去し、クライアントとアプリケーションまたはサービスの間で要求とデータを渡します。Protect applications and services by using a dedicated host instance that acts as a broker between clients and the application or service, validates and sanitizes requests, and passes requests and data between them.
ゲートウェイ集約Gateway Aggregation ゲートウェイを使用して、複数の個々の要求を 1 つの要求に集約します。Use a gateway to aggregate multiple individual requests into a single request.
ゲートウェイ オフロードGateway Offloading 共有または専用のサービス機能の負荷をゲートウェイ プロキシに渡します。Offload shared or specialized service functionality to a gateway proxy.
ゲートウェイ ルーティングGateway Routing 単一のエンドポイントを使用して複数のサービスに要求をルーティングします。Route requests to multiple services using a single endpoint.
正常性エンドポイント監視Health Endpoint Monitoring 公開されたエンドポイントを通じて外部ツールが定期的にアクセスできる機能チェックをアプリケーションに実装します。Implement functional checks in an application that external tools can access through exposed endpoints at regular intervals.
テーブルのインデックス作成Index Table クエリで頻繁に参照されるデータ ストア内のフィールドにインデックスを作成します。Create indexes over the fields in data stores that are frequently referenced by queries.
リーダー選定Leader Election 1 つのインスタンスを他のインスタンスの管理を担当するリーダーとして選定することで、分散アプリケーション内で連携するタスク インスタンスのコレクションによって実行されるアクションを調整します。Coordinate the actions performed by a collection of collaborating task instances in a distributed application by electing one instance as the leader that assumes responsibility for managing the other instances.
具体化されたビューMaterialized View 必要なクエリ操作に対してデータのフォーマットが適していない場合に、1 つ以上のデータ ストアのデータについてあらかじめデータが移入されたビューを生成します。Generate prepopulated views over the data in one or more data stores when the data isn't ideally formatted for required query operations.
パイプとフィルターPipes and Filters 複雑な処理を実行するタスクを、再利用できる一連の独立した要素に分解します。Break down a task that performs complex processing into a series of separate elements that can be reused.
優先順位キューPriority Queue サービスに送信される要求に優先順位を設定し、優先順位の高い要求から順番に受信および処理されるようにします。Prioritize requests sent to services so that requests with a higher priority are received and processed more quickly than those with a lower priority.
キュー ベースの負荷平準化Queue-Based Load Leveling タスクとそのタスクが呼び出すサービスとの間でバッファーとして機能するキューを使用して、断続的な大きい負荷を平準化します。Use a queue that acts as a buffer between a task and a service that it invokes in order to smooth intermittent heavy loads.
RetryRetry 予測される一時的な障害をアプリケーションが処理できるようにします。アプリケーションがサービスまたはネットワーク リソースに接続しようとする際に、失敗した操作を透過的に再試行します。Enable an application to handle anticipated, temporary failures when it tries to connect to a service or network resource by transparently retrying an operation that's previously failed.
Scheduler エージェント スーパーバイザーScheduler Agent Supervisor 分散されている一連のサービスやその他のリモート リソースに対して、一連のアクションを調整します。Coordinate a set of actions across a distributed set of services and other remote resources.
シャーディングSharding データ ストアを水平方向のパーティションまたはシャードのセットに分割します。Divide a data store into a set of horizontal partitions or shards.
SidecarSidecar アプリケーションのコンポーネントを別のプロセスまたはコンテナーにデプロイして、分離性とカプセル化を実現します。Deploy components of an application into a separate process or container to provide isolation and encapsulation.
静的コンテンツ ホスティングStatic Content Hosting 静的コンテンツを、クライアントに直接配信できるクラウドベースのストレージ サービスにデプロイします。Deploy static content to a cloud-based storage service that can deliver them directly to the client.
ストラングラーStrangler 機能の特定の部分を新しいアプリケーションやサービスに徐々に置き換えることで、レガシ システムを段階的に移行します。Incrementally migrate a legacy system by gradually replacing specific pieces of functionality with new applications and services.
調整Throttling アプリケーションのインスタンス、個々のテナント、またはサービス全体によって使用されるリソースの使用量を制御します。Control the consumption of resources used by an instance of an application, an individual tenant, or an entire service.
バレット キーValet Key 特定のリソースまたはサービスへの限定的な直接アクセスをクライアントに提供する、トークンまたはキーを使用します。Use a token or key that provides clients with restricted direct access to a specific resource or service.