Java 8 はサポートが終了しており、2026 年 1 月 31 日に
非推奨になります。非推奨になると、過去に組織のポリシーを使用して以前のランタイムのデプロイを再度有効にしていた場合でも、Java 8 アプリケーションをデプロイできなくなります。既存の Java 8 アプリケーションは、
非推奨になる日付以降も引き続き実行され、トラフィックを受信します。
サポートされている最新バージョンの Java に移行することをおすすめします。
Google App Engine 上でのマイクロサービス アーキテクチャ
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
マイクロサービスは、アプリケーション開発におけるアーキテクチャ スタイルの一つです。マイクロサービスによって、大きなアプリケーションを、それぞれが独自の責任範囲を持つ独立した構成要素に分解できます。単一のユーザー リクエストまたは API リクエストを受け取ると、マイクロサービスベースのアプリケーションは多くの内部マイクロサービスを呼び出して、レスポンスを作成します。
正しく実装されたマイクロサービスベースのアプリケーションは、以下の目的を達成します。
- さまざまなマイクロサービスの間に厳密なコントラクトを定義する。
- 独立したデプロイ サイクル(ロールバックを含む)を可能にする。
- サブシステム上での A/B リリーステストの同時実行を促進する。
- テスト自動化と品質保証のオーバーヘッドを最小化する。
- ロギングとモニタリングの明瞭性を改善する。
- より詳細な費用計算を提供する。
- アプリケーションのスケーラビリティと信頼性を高める。
Google App Engine にはマイクロサービスベースのアプリケーションに最適なたくさんの機能があります。ここでは、Google App Engine で実行するマイクロサービスベースのアプリケーションとして自分のアプリケーションをデプロイする際に利用できるおすすめの方法の概略を説明します。
マイクロサービスとしての App Engine サービス
1 つの App Engine プロジェクトでは、複数のマイクロサービスを別個のサービスとしてデプロイできます(App Engine でサービスは以前「モジュール」と呼ばれていました)。マイクロサービスではコードが完全に分離されます。したがって、これらのサービスでコードを実行する方法は、HTTP 呼び出し(ユーザー リクエストや RESTful API 呼び出しなど)のみです。あるサービスのコードが別のサービスのコードを直接呼び出すことはできません。コードを複数のサービスに別々にデプロイすることが可能で、異なるサービスを異なる言語(Python、Java、Go、PHP など)で作成することもできます。自動スケーリング、ロード バランシング、マシン インスタンスのタイプはすべてサービスごとに独立して管理されます。

サービス内部での複数のバージョン
さらに、それぞれのサービスについて同時に複数のバージョンをデプロイできます。それらのバージョンのうちのいずれか 1 つがそのサービスのデフォルトのバージョンとして機能しますが、サービスの各バージョンはそれぞれ独自のアドレスを持っているので、デプロイされた任意のバージョンに直接アクセスすることが可能です。このような構造のおかげで、新規バージョンのスモークテスト、異なるバージョン間の A/B テスト、ロール フォワードとロールバックの簡易操作など、行えることは限りなく広がります。App Engine フレームワークには、これらの多くを支援するメカニズムが用意されています。それらのメカニズムについては、後のセクションで詳しく説明します。

サービスの分離
サービスはその大部分が分離されていますが、App Engine リソースの一部を共有しています。たとえば、Cloud Datastore、Memcache、タスクキューはすべて同じ App Engine プロジェクトに属するサービスの共有リソースです。これらのリソースを共有することにはいくつかの利点もありますが、マイクロサービスベースのアプリケーションでは、マイクロサービス間でコードとデータの分離が維持されている点が重要です。不必要にリソースを共有することで受ける影響を軽減するのに役立つアーキテクチャ パターンがいくつか用意されています。それらのパターンについては、この記事の後半で説明します。

プロジェクトの分離
アーキテクチャ パターンに依存した分離ではなく、より秩序だった手法で分離を行うには、複数の App Engine プロジェクトを使用します。ここでサービスではなくプロジェクトを利用することには長所と短所があるので、実際の状況を念頭に置いてバランスを考慮する必要があります。複数のプロジェクトを使用することの利点が特に必要とされる状況でない限り、まずは 1 つのプロジェクト内で複数のサービスを使用することから始めるのが最善です。そのほうがパフォーマンスに優れ、管理オーバーヘッドも最低限で済むからです。もちろん、サービスの使用とプロジェクトの使用を融合させた方法も選択できます。
サービスの分離とプロジェクトの分離の比較
次の表に、マイクロサービス アーキテクチャにおいて複数のサービスを使用した場合と複数のプロジェクトを使用した場合の比較を示します。
|
複数のサービス
|
複数のプロジェクト
|
コードの分離
|
デプロイされるコードは、サービスごと、バージョンごとに完全に独立している。
|
デプロイされるコードは、プロジェクトごとに完全に独立しており、各プロジェクトのサービスごと、バージョンごとにも完全に独立している。
|
データの分離
|
Cloud Datastore と Memcache はすべてのサービスとバージョンで共有されるが、名前空間をデベロッパー パターンとして使用することによりデータを分離できる。
タスクキューを分離するには、キュー名のデベロッパー命名規則を利用して、user-service-queue-1 のようにすることができる。 |
Cloud Datastore、Memcache、タスクキューはプロジェクトごとに完全に独立している。
|
ログの分離
|
各サービス(と各バージョン)のログはそれぞれ独立しているが、それらのログを同時に表示することも可能。 |
各プロジェクト(および各プロジェクトのサービスとバージョン)のログはそれぞれ独立しているが、同一プロジェクトのすべてのログを同時に表示することも可能。
ただし、複数のプロジェクトのログを同時に表示することはできない。
|
パフォーマンスのオーバーヘッド
|
同一プロジェクトのサービスは同じデータセンターにデプロイされるため、あるサービスが HTTP で別のサービスを呼び出す場合のレイテンシは非常に低い。
|
プロジェクトがデプロイされるデータセンターはそれぞれ異なる場合があるため、HTTP レイテンシが上がるかもしれないが、Google のネットワークは世界トップレベルなので、上がるとしてもかなり低い。
|
費用計算
|
インスタンス時間の費用(コードの実行に要する CPU とメモリ)はサービスごとに分離されない。プロジェクト全体のインスタンス時間すべてが一括で扱われる。
|
プロジェクトごとの費用は分離されるので、マイクロサービスごとの費用の確認が非常に簡単。
|
オペレーターの権限
|
オペレーターは、プロジェクト内のすべてのサービスについて、コードのデプロイ、バージョンのロール フォワードとロールバック、ログの表示を行うことができる。
特定のサービスに対するアクセスを制限することはできない。
|
個々のプロジェクトごとにオペレーターのアクセス権を制御できる。
|
リクエストのトレース |
Google Cloud Trace を使用して、同一プロジェクト内のサービスについて、リクエストとその結果生じるマイクロサービスのリクエストを 1 つの合成トレースとして表示できる。この機能のおかげで、パフォーマンス調整が行いやすい。 |
Cloud Trace の呼び出しは、同じ組織に含まれている GCP プロジェクト間で可視化できる。 |
次のステップ
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-09-04 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-09-04 UTC。"],[[["\u003cp\u003eMicroservices decompose large applications into independent parts, each with its own responsibility, allowing a single request to involve multiple internal microservices.\u003c/p\u003e\n"],["\u003cp\u003eApp Engine enables deploying microservices as separate services, offering code isolation, independent deployment cycles, and the ability to use different programming languages.\u003c/p\u003e\n"],["\u003cp\u003eWithin each service, multiple versions can run simultaneously, facilitating A/B testing, smoke testing, and easy rollback/roll-forward operations.\u003c/p\u003e\n"],["\u003cp\u003eServices within an App Engine project share resources like Cloud Datastore and Memcache, but data isolation can be achieved using namespaces and distinct queue names, or you can use multiple App Engine projects for more formal isolation.\u003c/p\u003e\n"],["\u003cp\u003eUsing multiple services within a single project generally offers lower latency and less administrative overhead than using multiple projects, though multiple projects offer increased isolation and cost separation.\u003c/p\u003e\n"]]],[],null,["# Microservices Architecture on Google App Engine\n\n*Microservices* refers to an architectural style for\ndeveloping applications. Microservices allow a large application to be\ndecomposed into independent constituent parts, with each part having its own\nrealm of responsibility. To serve a single user or API request,\na microservices-based application can call many internal microservices\nto compose its response.\n\nA properly implemented microservices-based application can achieve the\nfollowing goals:\n\n- Define strong contracts between the various microservices.\n- Allow for independent deployment cycles, including rollback.\n- Facilitate concurrent, A/B release testing on subsystems.\n- Minimize test automation and quality-assurance overhead.\n- Improve clarity of logging and monitoring.\n- Provide fine-grained cost accounting.\n- Increase overall application scalability and reliability.\n\nGoogle App Engine has a number of features that are well-suited for a\nmicroservices-based application. This page outlines best practices to use\nwhen deploying your application as a microservices-based application on Google\nApp Engine.\n\nApp Engine Services as microservices\n------------------------------------\n\nIn an App Engine project, you can deploy multiple microservices as separate\n*[services](/appengine/docs/legacy/standard/java/an-overview-of-app-engine)* , previously known as\n*modules* in App Engine. These services have full isolation of code; the only\nway to execute code in these services is through an HTTP invocation, such as a\nuser request or a RESTful API call. Code in one service can't directly call code\nin another service. Code can be deployed to services independently, and\ndifferent services can be written in different languages, such as Python, Java,\nGo, and PHP. Autoscaling, load balancing, and machine instance types are all\nmanaged independently for services.\n\nVersions within services\n------------------------\n\nFurthermore, each service can have multiple *versions* deployed simultaneously.\nFor each service, one of these versions is the default serving version, though\nit is possible to directly access any deployed version of a service as each\nversion of each service has its own address. This structure opens up myriad\npossibilities, including smoke testing a new version, A/B testing between\ndifferent versions, and simplified roll-forward and rollback operations. The App\nEngine framework provides mechanisms to assist with most of these items. We'll\ncover these mechanisms in more detail in upcoming sections.\n\nService isolation\n-----------------\n\nThough mostly isolated, services share some App Engine resources. For example,\nCloud Datastore, Memcache, and Task Queues are all shared resources between services\nin an App Engine project. While this sharing has some advantages,\nit's important for a microservices-based application to maintain code- and\ndata-isolation between microservices. There are architecture patterns that help\nmitigate unwanted sharing. We'll describe these patterns later in this article.\n\nProject isolation\n-----------------\n\nIf you don't want to rely on these patterns to achieve isolation and you want a\nmore formal enforcement of separation, you can use multiple App Engine projects.\nThere are pros and cons to using projects instead of services, and you must\nbalance the tradeoffs depending on your situation. Unless you have a specific\nneed for one of the advantages offered by using multiple projects, it's best to\nstart with using multiple services within a single project because performance\nwill be better and the administrative overhead will be minimized. Of course, you\ncan also choose some hybrid of the two approaches.\n\nComparison of service isolation and project isolation\n-----------------------------------------------------\n\nThe following table provides a comparison between using multiple services and\nmultiple projects in a microservices architecture:\n\nWhat's next\n-----------\n\n- Understand how to [create and name dev, test, qa, staging, and production environments with microservices in App Engine](/appengine/docs/legacy/standard/java/creating-separate-dev-environments).\n- Learn the [best practices for designing APIs to communicate between microservices](/appengine/docs/legacy/standard/java/designing-microservice-api).\n- Learn the [best practices for microservice performance](/appengine/docs/legacy/standard/java/microservice-performance).\n- Learn how to [Migrate an existing monolithic application to one with microservices](/appengine/docs/legacy/standard/java/microservice-migration).\n- Understand if microservices are ideal for your situation. On his personal blog, Google Solution Architect Preston Holmes has [published a post about some of the drawbacks](http://www.ptone.com/dablog/2015/07/microservices-may-be-the-new-premature-optimization/) he sees in microservices."]]