이 페이지에서는 Spanner 요청과 관련된 상위 수준 구성요소를 간략하게 설명하고 각 구성요소가 지연 시간에 어떤 영향을 미치는지 보여줍니다.
Spanner API 요청
Spanner API 요청을 전송하는 데 사용되는 상위 구성요소는 다음과 같습니다.
Spanner 클라이언트 라이브러리: gRPC 기반의 추상화 레이어를 제공하고 세션 관리, 트랜잭션, 재시도와 같은 서버 통신 세부정보를 처리합니다.
Google 프런트엔드(GFE): Spanner를 포함한 모든 Google Cloud 서비스에 공통적으로 해당되는 인프라 서비스입니다. GFE는 모든 전송 계층 보안(TLS) 연결이 중지되었는지 확인하고 서비스 거부 공격에 대한 보호를 적용합니다. GFE에 관한 자세한 내용은 Google 프런트엔드 서비스를 참조하세요.
Spanner API 프런트엔드: API 요청에 대한 다양한 검사(인증, 승인, 할당량 확인 포함)를 수행하고 세션과 트랜잭션 상태를 유지합니다.
Spanner 데이터베이스: 데이터베이스에 대한 읽기 및 쓰기를 실행합니다.
Spanner에 대한 리모트 프로시져 콜을 수행하면 Spanner 클라이언트 라이브러리가 API 요청을 준비합니다. 그런 다음 API 요청이 GFE와 Spanner API 프런트엔드를 모두 통과한 후 Spanner 데이터베이스에 도달합니다.
여러 구성요소와 데이터베이스 간의 요청 지연 시간을 측정하고 비교하면 문제를 일으키는 구성요소를 확인할 수 있습니다.
이러한 지연 시간에는 클라이언트 왕복, GFE, Spanner API 요청, 쿼리 지연 시간이 포함됩니다.
다음 섹션에서는 이전 다이어그램에 표시된 각 지연 시간 유형을 설명합니다.
클라이언트 왕복 지연 시간
클라이언트 왕복 지연 시간은 클라이언트가 GFE 및 Spanner API 프런트엔드를 통해 데이터베이스로 전송한 Spanner API 요청의 첫 번째 바이트와 클라이언트가 데이터베이스에서 수신한 응답의 마지막 바이트 사이의 시간(밀리초)입니다.
Google 프런트엔드(GFE) 지연 시간은 Google 네트워크에서 클라이언트의 리모트 프로시져 콜을 수신한 후 GFE가 응답의 첫 번째 바이트를 수신할 때까지의 시간(밀리초)입니다. 이 지연 시간은 TCP/SSL 핸드셰이크를 포함하지 않습니다.
Spanner의 모든 응답에는 REST 또는 gRPC에 관계없이 GFE와 백엔드(Spanner 서비스) 사이에 요청부터 응답까지 소요된 총 시간이 포함된 헤더가 있습니다. 이렇게 하면 클라이언트와 Google 네트워크 간의 지연 시간이 발생하는 원인을 더 잘 파악할 수 있습니다.
spanner/gfe_latency 측정항목은 Spanner 요청의 GFE 지연 시간을 캡처하고 노출합니다.
Spanner API 요청 지연 시간은 Spanner API 프런트엔드에서 수신한 요청의 첫 번째 바이트와 Spanner API 프런트엔드에서 전송한 응답의 마지막 바이트 간의 시간(초)입니다. 이 지연 시간에는 Spanner 백엔드와 API 레이어 모두에서 API 요청을 처리하는 데 필요한 시간이 포함됩니다.
그러나 Spanner 클라이언트와 서버 간의 네트워크 또는 역방향 프록시 오버헤드는 이 지연 시간에 포함되지 않습니다.
spanner.googleapis.com/api/request_latencies 측정항목은 Spanner 요청의 Spanner API 프런트엔드 지연 시간을 캡처하고 노출합니다.
QueryMode 파라미터가 WITH_STATS 또는 WITH_PLAN_AND_STATS로 설정된 경우 Spanner의 ResultSetStats가 응답에 제공됩니다. 또한 ResultSetStats에는 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-06-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."]]