プリンキピア

第12章クラウドネイティブアプリケーション開発

CONCEPTS IN PRACTICE実践の中の概念
Microservices Architecture and Cloud-Native Applicationsマイクロサービスアーキテクチャとクラウドネイティブアプリケーション
As discussed in Chapter 9 Software Engineering and Chapter 10 Enterprise and Solution Architectures Management, architectural styles, architectural patterns, and design patterns are typically used to enforce the quality attributes of software solutions. The microservices architectural style is used to break monolithic applications into smaller services based on business capabilities. It is partially based on the SOA style but does not rely on an enterprise service bus to enable communication between services.
第9章「ソフトウェア工学」と第10章「エンタープライズアーキテクチャとソリューションアーキテクチャの管理」で述べたように、アーキテクチャスタイル、アーキテクチャパターン、デザインパターンは、ソフトウェアによる解決策の品質属性を確実に満たすために使われる。マイクロサービスのアーキテクチャスタイルは、モノリシックなアプリケーションを、事業機能に基づく小さなサービスへ分けるために使う。SOAのスタイルを部分的に基にしているが、サービス間の通信にエンタープライズサービスバスを必要としない。
One example of a microservices design pattern is the Backend for Frontend (BFF) Microservice Design Pattern.4 This design pattern involves creating dedicated back-end services tailored to the specific needs of front-end clients. The goal of this pattern is to ensure an efficient and streamlined interaction between the front-end and back-end components. As an example of how to use this pattern, consider an e-commerce platform like the online products catalog sample described above. The e-commerce platform may serve both web and mobile client applications. Implementing the BFF pattern means creating dedicated back-end components that serve each client application. Because the user interactions between these two client applications are different, the APIs between these clients and the dedicated back-end services can be optimized to best suit those client types.
英語のヒント
マイクロサービスのデザインパターンの一例に、Backend for Frontend(BFF)マイクロサービス・デザインパターンがある。4 このパターンでは、フロントエンドのクライアントの具体的な必要に合わせた、専用のバックエンドサービスを作る。目標は、フロントエンドとバックエンドのコンポーネントが、効率よく円滑にやり取りできるようにすることである。使い方の例として、前述のオンライン商品カタログのような、電子商取引のプラットフォームを考えよう。プラットフォームは、Webとモバイルの両方のクライアントアプリケーションへサービスを提供する場合がある。BFFパターンの実装では、それぞれのクライアントに対応する専用のバックエンドコンポーネントを作る。2つのクライアントでは利用者の操作が異なるため、クライアントと専用バックエンドサービスの間のAPIを、それぞれのクライアントの種類に最適になるように調整できる。
In addition to optimizing the API gateway, the microservices architecture utilized also efficiently allocates resources to each service that a cloud-native application uses, making the application flexible and adaptable to a cloud architecture. Containers are an architectural pattern that is used to deploy microservices on any platform that operates a container engine runtime. Combining microservices and containers with another architectural pattern referred to as container orchestration makes it possible to scale, manage, and automate the deployment of containerized applications based on microservices. This is an example of how a combination of architectural styles and related patterns can drastically improve the quality of enterprise applications. However, as noted earlier, there are challenges associated with the use of microservices and other architectural styles that also must be considered when designing an enterprise solution.
英語のヒント
APIゲートウェイの最適化に加え、採用したマイクロサービスアーキテクチャは、クラウドネイティブアプリケーションが使う各サービスに資源を効率よく割り当て、アプリケーションを柔軟で、クラウドのアーキテクチャに適応しやすいものにする。コンテナーは、コンテナーエンジンのランタイムが動く任意のプラットフォームへ、マイクロサービスを配置するためのアーキテクチャパターンである。マイクロサービスとコンテナーを、コンテナーオーケストレーションと呼ばれる別のパターンと組み合わせると、マイクロサービスを基にしたコンテナー化アプリケーションの配置を拡張・管理・自動化できる。これは、アーキテクチャスタイルと関連するパターンの組み合わせが、企業向けアプリケーションの品質を大きく高める例である。しかし、前述したように、マイクロサービスやほかのアーキテクチャスタイルの利用には課題もあり、企業向けの解決策を設計する際に考慮しなければならない。
Microservices Challengesマイクロサービスの課題
Microservices enhance a development team’s ability to leverage distributed development. Development time can be reduced as microservices can be developed concurrently. However, there are known challenges to shifting to a microservices architecture. In addition to complexity and efficiency being two major challenges of a microservices-based architecture, the following eight challenge categories have been identified.
英語のヒント
マイクロサービスは、開発チームが分散開発を活用する能力を高める。複数のサービスを同時並行で開発できるため、開発時間を減らせる。しかし、マイクロサービスアーキテクチャへの移行には、知られている課題がある。複雑さと効率という2つの大きな課題に加え、次の8つの種類の課題が挙げられる。
Building Microservices
マイクロサービスのビルド
Some microservices may need to access other microservices to provide certain application functionality. This causes dependencies between microservices. Time must be spent identifying these dependencies. Added dependencies between microservices can result in completing one build that triggers several subsequent builds.
英語のヒント
あるマイクロサービスが、特定のアプリケーション機能を提供するため、ほかのマイクロサービスへアクセスする必要がある場合がある。これにより、サービス間に依存関係が生じる。その依存関係の特定には、時間をかけなければならない。依存関係が増えると、1つのビルドの完了が、その後の複数のビルドを引き起こす場合がある。
Another type of dependency is data sharing where one microservice may need access to data managed by another microservice. Some concerns with data sharing include scaling. As microservices are added, to provide data consistency and redundancy, a microservice that requires a schema change in a database must be shared with other microservices. These concerns should also be taken into consideration when addressing dependencies.
英語のヒント
別の種類の依存関係に、データの共有がある。1つのマイクロサービスが、別のサービスの管理するデータへアクセスする必要がある場合である。データ共有の懸念には、規模の拡張がある。マイクロサービスが追加されるにつれ、データの一貫性と冗長性を確保するため、データベースのスキーマ変更を必要とするマイクロサービスを、ほかのサービスと共有しなければならない。依存関係を扱う際には、これらの点も考慮する必要がある。
Microservices Connectivity
マイクロサービスの接続性
Microservices-based applications consist of several microservices that need to communicate with each other. Microservices run in containerized environments where the number of microservices instances and locations change dynamically. Service discovery can be used to locate each microservice instance. Without service discovery, a microservices-based application can be difficult to maintain.
英語のヒント
マイクロサービスを基にしたアプリケーションは、互いに通信する必要がある複数のサービスからなる。各サービスは、インスタンスの数や場所が動的に変わる、コンテナー化された環境で動作する。サービスディスカバリーを使えば、各サービスのインスタンスを見つけられる。これがないと、マイクロサービス型アプリケーションの保守は難しくなりうる。
Versioning of Microservices
マイクロサービスのバージョン管理
A microservice might be updated to satisfy new requirements or address some design issues. Other microservices that depend on an older version of the updated microservice could fail. Dependencies between microservices when updating a microservice can lead to breaking backward compatibility. One way to address this is to build in conditional logic that either appends the version number or tracks versioning, which can become difficult to manage. Alternatively, multiple live versions can be provided for different clients, but they can also become difficult to manage.
英語のヒント
新しい要件を満たしたり、設計上の問題に対処したりするため、マイクロサービスを更新する場合がある。更新されたサービスの古い版に依存するほかのマイクロサービスが、動かなくなる可能性がある。マイクロサービス間の依存関係は、あるサービスを更新した際、後方互換性を壊す原因になりうる。対処方法の1つは、バージョン番号を付加するか、バージョンを追跡する条件分岐を組み込むことだが、管理が難しくなることがある。別の方法は、異なるクライアント向けに複数の稼働中の版を提供することだが、それらも管理が難しくなる場合がある。
4 https://aws.amazon.com/blogs/mobile/backends-for-frontends-pattern/
4 https://aws.amazon.com/blogs/mobile/backends-for-frontends-pattern/
Testing Microservices
マイクロサービスのテスト
Testing microservices can become more challenging, particularly with integration testing and end-to-end testing. A single transaction carried out in an application can span across multiple microservices. A failure in one microservice can lead to failures in other microservices. In addition, failures can occur in the microservice itself, in its container, or in the network interconnecting the microservices, making it more challenging to design integration tests. For these reasons, an integration test plan should factor in interdependencies between microservices.
英語のヒント
マイクロサービスのテスト、特に統合テストと端から端までのテストは、難しくなる場合がある。アプリケーション内で行う1つの取引が、複数のマイクロサービスにまたがることがある。1つのサービスの障害は、ほかのサービスの障害へつながりうる。また、障害は、サービス自体、コンテナー、サービス同士をつなぐネットワークのいずれでも起こりうるため、統合テストの設計はさらに難しくなる。そのため、統合テストの計画では、サービス間の相互依存を考慮すべきである。