Google Front End(GFE)。Spanner を含むすべての Google Cloud サービスに共通のインフラストラクチャ サービスです。GFE は、すべての Transport Layer Security(TLS)接続が停止していることを確認し、サービス拒否攻撃に対する保護を適用します。GFE の詳細については、Google Front End サービスをご覧ください。
Cloud Spanner API フロントエンド(AFE)。API リクエストに対してさまざまなチェック(認証、承認、割り当てチェック)が実施され、セッションとトランザクションの状態が維持されます。
Spanner API リクエストのレイテンシは、Spanner AFE が受信したリクエストの最初のバイトから Spanner API フロントエンドが送信したレスポンスの最後のバイトまでの時間(秒単位)です。レイテンシには、Spanner バックエンドと API レイヤの両方で API リクエストの処理に必要な時間が含まれます。ただし、このレイテンシには、Spanner クライアントとサーバーの間のネットワークやリバース プロキシのオーバーヘッドは含まれません。
[[["わかりやすい","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-03 UTC。"],[],[],null,["# Latency points in a Spanner request\n\n| **Note:** [OpenCensus is deprecated](https://opentelemetry.io/blog/2023/sunsetting-opencensus/). We recommend using OpenTelemetry to capture and visualize Spanner observability metrics. For more information, see [Capture custom client-side metrics using OpenTelemetry](/spanner/docs/capture-custom-metrics-opentelemetry).\n\nThis page gives an overview of the high-level components involved in a\nSpanner request and how each component can affect latency.\n\nSpanner API requests\n--------------------\n\nThe high-level components that are used to make a Spanner API\nrequest include:\n\n- [Spanner client libraries](/spanner/docs/reference/libraries),\n which provide a layer of abstraction on top of gRPC, and handle server\n communication details, such as session management, transactions, and retries.\n\n- The Google Front End (GFE), which is an infrastructure service that's common\n to all Google Cloud services, including Spanner. The\n GFE verifies that all Transport Layer Security (TLS) connections are stopped\n and applies protections against Denial of Service attacks. To learn more\n about the GFE, see [Google Front End Service](/docs/security/infrastructure/design#google-frontend-service).\n\n- The Spanner API frontend (AFE), which performs various checks\n on the API request (including authentication, authorization, and quota checks)\n , and maintains sessions and transaction states.\n\n- The Spanner database, which executes reads and writes to the\n database.\n\nWhen you make a remote procedure call to Spanner, the\nSpanner client libraries prepare the API request. Then, the API\nrequest passes through both the GFE and the Spanner AFE\nbefore reaching the Spanner database.\n\nBy measuring and comparing the request latencies between different components\nand the database, you can determine which component is causing the problem.\nThese latencies include client round-trip, GFE, Spanner API\nrequest, and query latencies.\n\nThe following sections explain each type of latency you see in the previous\ndiagram.\n\nClient round-trip latency\n-------------------------\n\nClient round-trip latency is the length of time (in milliseconds) between the\nfirst byte of the Spanner API request that the client sends to\nthe database (through both the GFE and the Spanner API front\nend), and the last byte of response that the client receives from the database.\n\nThe [`grpc.io/client/roundtrip_latency`](https://github.com/census-instrumentation/opencensus-specs/blob/master/stats/gRPC.md#default-views)\nmetric provides the time between the first byte of the API request sent to the\nlast byte of the response received.\n\nTo capture and visualize latency for this component, see\n[Capture client round-trip latency with OpenTelemetry](/spanner/docs/capture-custom-metrics-opentelemetry#capture-client-round-trip-latency)\nor [with OpenCensus](/spanner/docs/capture-visualize-latency-opencensus#capture_and_visualize_client_round-trip_latency).\n\nGFE latency\n-----------\n\nGoogle Front End (GFE) latency is the length of time (in milliseconds) between\nwhen the Google network receives a remote procedure call from the client and\nwhen the GFE receives the first byte of the response. This latency doesn't\ninclude any TCP/SSL handshake.\n\nEvery response from Spanner, whether it's REST or gRPC, includes\na header that contains the total time between the GFE and the backend (the\nSpanner service) for both the request and the response. This\nhelps to differentiate better the source of the latency between the client\nand the Google network.\n\nThe `spanner/gfe_latency`\nmetric captures and exposes GFE latency for Spanner requests.\n\nTo capture and visualize latency for this component, see\n[Capture GFE latency with OpenTelemetry](/spanner/docs/capture-custom-metrics-opentelemetry#capture-gfe-latency)\nor [with OpenCensus](/spanner/docs/capture-visualize-latency-opencensus#capture_and_visualize_gfe_latency).\n\nSpanner API request latency\n---------------------------\n\nSpanner API request latency is the length of time (in seconds)\nbetween the first byte of request that the Spanner AFE\nreceives and the last byte of response that the Spanner API\nfrontend sends. The latency includes the time needed for processing API\nrequests in both the Spanner backend and the API layer.\nHowever, this latency doesn't include network or reverse-proxy overhead\nbetween Spanner clients and servers.\n\nThe `spanner.googleapis.com/api/request_latencies` metric captures\nand exposes Spanner AFE latency for\nSpanner requests.\n\nTo capture and visualize latency for this component, see\n[Capture Spanner API request latency with OpenTelemetry](/spanner/docs/capture-custom-metrics-opentelemetry#capture-spanner-api-request-latency)\nor [with OpenCensus](/spanner/docs/capture-visualize-latency-opencensus#capture_and_visualize_api_request_latency).\n\nQuery latency\n-------------\n\nQuery latency is the length of time (in milliseconds) that it takes to run SQL\nqueries in the Spanner database.\n\nQuery latency is available for the [executeSql](/spanner/docs/reference/rpc/google.spanner.v1#ExecuteSqlRequest) API.\n\nIf the [`QueryMode`](/spanner/docs/reference/rpc/google.spanner.v1#querymode)\nparameter is set to `WITH_STATS` or `WITH_PLAN_AND_STATS`, then Spanner's\n[`ResultSetStats`](/spanner/docs/reference/rpc/google.spanner.v1#resultsetstats)\nare available in the responses. `ResultSetStats` includes the elapsed time for running queries in\nthe Spanner database.\n\nTo capture and visualize latency for this component, see\n[Capture query latency with OpenTelemetry](/spanner/docs/capture-custom-metrics-opentelemetry#capture-query-latency)\nor [with OpenCensus](/spanner/docs/capture-visualize-latency-opencensus#capture_and_visualize_query_latency).\n\nWhat's next\n-----------\n\n- Learn how to [identify latency points](/spanner/docs/identify-latency-point) in Spanner components."]]