Microsoft Azure版デザインパターン41個を1行で説明する[3/3:Q~Z]

第一部、第二部に引き続き、Microsoftがサイトに乗せているデザインパターン41個のうち最後の12個を紹介する。


Queue-Based Load Leveling pattern

Use a queue that acts as a buffer between a task and a service it invokes in order to smooth intermittent heavy loads that can cause the service to fail or the task to time out. This can help to minimize the impact of peaks in demand on availability and responsiveness for both the task and the service.

キューをタスクとサービスの間のバッファとして使い、タイムアウトが生じるような重い負荷についても途切れなくinvokej(呼び出し)できるようにするというパターン。

Rate Limiting pattern

Many services use a throttling pattern to control the resources they consume, imposing limits on the rate at which other applications or services can access them. You can use a rate limiting pattern to help you avoid or minimize throttling errors related to these throttling limits and to help you more accurately predict throughput.

rate limitting patternは、後述するthrottling patternでは処理しきれないタスクをthrottle(絞る)のに対し、ボトルネックとなる処理の手前でrate limitを設けることで、結果としてスループットが高くなるという話。

Retry pattern

Enable an application to handle transient failures when it tries to connect to a service or network resource, by transparently retrying a failed operation. This can improve the stability of the application.

これは、、、名前の通り。

Saga distributed transactions

The saga design pattern is a way to manage data consistency across microservices in distributed transaction scenarios. A saga is a sequence of transactions that updates each service and publishes a message or event to trigger the next transaction step. If a step fails, the saga executes compensating transactions that counteract the preceding transactions.

sagaは分散トランザクションでデータの一貫性を管理する方法で、前述のオーケストレータやコリオグラフィーといったパターンと組み合わせて用いられる。

「トライライト・サーガ」などフィクションのタイトルに出てくる「サーガ」は叙事詩のような意味合い。「マイクロサービスパターン」を書いたChris RichardsonのブログによるとA saga is a sequence of local transactions in each of the participating services.(参加しているサービスの一連のトランザクション)だと説明していて、ここから「叙事詩」を思い浮かんだのだろうか。

Scheduler Agent Supervisor pattern

Coordinate a set of distributed actions as a single operation. If any of the actions fail, try to handle the failures transparently, or else undo the work that was performed, so the entire operation succeeds or fails as a whole. This can add resiliency to a distributed system, by enabling it to recover and retry actions that fail due to transient exceptions, long-lasting faults, and process failures.

SchedulerとAgentとSupervisorの3つのアクターを用意し、Schedulerは未処理のタスクが残っていればAgentに処理を依頼するという役割、Supervisorは未処理のタスクの失敗回数が上限を超えたら処理を停止させるという役割にすることで、複雑な一連の処理のどこかひとつでも失敗したら全体が失敗するようにするというパターン。

第2回に出てきたPriority Queue patternとセットというか、Priority Queue patternを実装するなら、ここまで考慮しないと人力で対応しなければならなくなる。

Sequential Convoy pattern

Process a set of related messages in a defined order, without blocking processing of other groups of messages.

流れてきたメッセージを順序通りに処理しますよというパターン。

多分、順序通りにやらないPriority Queue patternを説明するために、順序通りに処理するだけのことにも名前を付けたんじゃないかと想像してます。

Sharding pattern

Divide a data store into a set of horizontal partitions or shards. This can improve scalability when storing and accessing large volumes of data.

データストアは大きくなりすぎるとレスポンスが悪くなるので水平パーティションもしくはシャードに分割しましょうという話。

Sidecar pattern

Deploy components of an application into a separate process or container to provide isolation and encapsulation. This pattern can also enable applications to be composed of heterogeneous components and technologies.

アプリケーションのコンポーネントをアプリケーション本体とは別のコンテナにデプロイするというパターン。

例ではアプリケーション本体をオートバイ、監視やログ出力をサイドカーに乗せている。そうすることでアプリケーション側のコンテナにはアプリケーションの動作に必要なものだけを乗せ、監視やログのコンテナには監視やログに必要なものだけをのせるということができる。

Static Content Hosting pattern

Deploy static content to a cloud-based storage service that can deliver them directly to the client. This can reduce the need for potentially expensive compute instances.

静的コンテンツをクラウド上のストレージにデプロイするとクライアントへ直で配信できますよという話。クラウドにかかる費用も削減できる。

Strangler Fig pattern

Incrementally migrate a legacy system by gradually replacing specific pieces of functionality with new applications and services. As features from the legacy system are replaced, the new system eventually replaces all of the old system's features, strangling the old system and allowing you to decommission it.

レガシーを徐々に新しいアプリケーションに移行させるという話。

strangleは「絞め殺す」という意味。

Throttling pattern

Control the consumption of resources used by an instance of an application, an individual tenant, or an entire service. This can allow the system to continue to function and meet service level agreements, even when an increase in demand places an extreme load on resources.

リソース消費量を制御することでシステムに極端な負荷がかかってもサービスを維持できるようにするという話。

前述のRate Limittingとの対ですね。

Valet Key pattern

Use a token that provides clients with restricted direct access to a specific resource, in order to offload data transfer from the application. This is particularly useful in applications that use cloud-hosted storage systems or queues, and can minimize cost and maximize scalability and performance.

アプリケーションからのデータ転送をオフロードするために、アプリケーションに制限付きのアクセスができるアクセストークンを使うというパターン。

valetはホテルのボーイさんのこと。ボーイさんに車を預けて駐車するときにトランクなどを開けられると困るから、エンジンだけ掛けられる鍵を作ることがあるらしいのだが、そのときに使う鍵をvalet keyと呼ぶらしい。

ということで全41個を読んでみた。

自分が意図して設計したわけではないが、知らないうちに慣習的にやっているようなことが言語化されていて、なおかつイラストまで豊富だ。リモートワークでアーキテクチャを議論するときにホワイトボードがなくてイメージを伝えるのが面倒なことが多いが、Microsoftのデザパタに載ってた絵を使えば相手に伝わりやすいのではという期待もある。

また、これだけの量を見てると中途半端なデザインパターンにモヤモヤするものを感じることもあり、自分でデザインパターンを作ってみたくもなる。でも、偉い人が独りよがりな例え話をし始めるのって好きじゃないから、やっぱりMicrosoftのように有名な著作物で語られてきたことを寄せ集めるのがよさそうだとも思う。



この記事が気に入ったらサポートをしてみませんか?