API 게이트웨이는 API를 위해 관리, 모니터링, 인증을 제공하는 API 관리 시스템입니다. API 게이트웨이에 포함된 구성요소는 다음과 같습니다.
API 게이트웨이: 배포된 API의 모든 특성을 관리합니다.
Service Control: API 관리 규칙을 적용합니다.
Service Management: API 구성을 관리합니다.
gcloud CLI: API를 배포 및 관리합니다.
Google Cloud console: 로깅, 모니터링, 공유를 지원합니다.
아키텍처
다음은 API 게이트웨이에 관련된 주요 구성요소를 보여주는 개괄적인 다이어그램입니다.
이 다이어그램에 대한 설명은 다음과 같습니다.
API 제공업체는 API 게이트웨이에서 API 만들기 및 배포를 수행합니다. 각 API는 OpenAPI 2.0 사양에 따라 기록된 파일로 정의됩니다.
OpenAPI 사양에 따라 API에 대한 REST 엔드포인트의 공개 연결 URL, API로 액세스되는 백엔드 서비스, 인증, 데이터 형식, 응답 옵션과 같은 API의 기타 특성이 정의됩니다.
API 클라이언트는 API 게이트웨이에 호스팅된 API에 대해 REST 요청을 수행하여 백엔드 서비스에 액세스합니다. API 클라이언트는 브라우저, 모바일 앱, 웹 앱 등 REST 호출을 수행할 수 있는 모든 앱일 수 있습니다.
API 클라이언트는 API의 URL, 요청 동사(예: GET, PUT, POST, DELETE), 모든 인증 요구사항, API에 송수신되는 데이터의 형식만 알면 됩니다.
API 클라이언트는 백엔드 구현에 대해 어떤 것도 알 필요가 없습니다. 실제로 요청에 전달된 정보에 따라 서로 다른 백엔드에 액세스하도록 API 게이트웨이에서 호스팅되는 단일 API를 구성할 수 있습니다.
API 게이트웨이 구성요소
API 게이트웨이
API 게이트웨이는 API 호스팅을 위해 완전 관리형의 종량제 요금 솔루션을 제공합니다. API 게이트웨이는 서비스 구현에 관계없이 모든 서비스에서 명확하게 정의되고 일관된 REST API를 통해 백엔드 서비스에 안전하게 액세스할 수 있게 해줍니다.
API 게이트웨이는 Google Cloud 와 통합됩니다. 따라서 다른 Google Cloud 제품에 사용하는 것과 동일한 개발, 모니터링, 로깅, 추적 도구를 사용할 수 있습니다.
Google Cloud외부에서 호스팅되는 백엔드 서비스에 연결하는 경우 API에 대한 액세스 제어에 사용되는 인증 및 승인 서비스를 포함하여 모든 Google Cloud 서비스를 활용할 수 있습니다.
Service Control API
Service Control API는 API 키 인증, 모니터링, 로깅과 같은 API 관리 규칙을 런타임에 적용합니다. Service Control은 다음과 같은 방법을 제공합니다.
확인 - 인증과 API 키를 확인하고 호출이 허용되는지 여부를 나타냅니다.
보고 - 로깅와 모니터링을 위한 레코드 시스템을 알립니다.
Service Management API
OpenAPI 사양을 사용해서 API를 정의합니다. 그런 후 gcloud CLI를 사용해서 OpenAPI 사양을 Service Management에 업로드하여 API 구성을 만듭니다. 다른 개발자와의 API 공유, 여러 프로젝트에서 API 사용 설정 또는 사용 중지, API 키 생성과 같은 다른 구성 관련 작업도 여기에서 수행됩니다.
gcloud CLI
gcloud CLI는 다양한 Google Cloud 서비스를 호출하는 데 사용할 수 있는 gcloud 명령줄 도구를 제공합니다. Google Cloud CLI를 사용해서 OpenAPI 사양을 업로드하여 API 구성을 만든 후 API 게이트웨이에 API 구성을 배포합니다.
Cloud 콘솔
Google Cloud 콘솔은 Google Cloud 콘솔의 그래픽 사용자 인터페이스입니다. Google Cloud 콘솔을 사용하여 Service Control에서 기록된 모니터링 및 로깅 데이터를 노출하고, 인증 및 승인을 구성하고, 개발자가 API 호출을 위해 API 키를 생성하도록 합니다.
API 요청 처리
API 구성에는 두 가지 유형의 엔드포인트가 있습니다.
API 엔드포인트: 클라이언트에서 API 소비를 위해 사용되는 공개적으로 제공되는 엔드포인트를 정의합니다.
백엔드 엔드포인트: API에서 백엔드 서비스에 연결하기 위해 사용되는 엔드포인트를 정의합니다. HTTP 또는 HTTPS 액세스와 같은 보안 설정은 백엔드 서비스의 구현에 따라 정의됩니다.
API 엔드포인트 요청은 요청의 일부로 전달되는 모든 데이터를 포함하여 백엔드 엔드포인트로 전달됩니다. 서비스에서 반환되는 데이터를 포함하여 백엔드 서비스의 응답이 클라이언트에 다시 전달됩니다.
요청 라우팅
요청이 수신되면 다음이 수행됩니다.
API 게이트웨이가 Cloud Trace에 대해 trace 토큰을 만듭니다.
API 게이트웨이는 수신 요청의 경로를 대상 API와 일치하는지 확인합니다. 일치하는 경로를 찾았으면 API 게이트웨이가 지정된 API에 대해 인증 단계를 수행합니다.
JWT 검증이 필요한 경우, API 게이트웨이가 서명자에 대해 적절한 공개 키를 사용하여 인증을 검증하고, JWT에서 대상 필드를 검증합니다. API 키가 필요한 경우, API 게이트웨이가 Service Control API를 호출하여 키를 검증합니다.
Service Control은 검증할 키를 조회하고, 키와 연관된 프로젝트가 API를 사용 설정했는지 확인합니다. 키가 유효하지 않거나 프로젝트가 API를 사용 설정하지 않았으면 호출이 거부되고 Service Control API를 통해 로깅됩니다.
Service Control이 키를 성공적으로 검증하면 모든 원본 헤더가 포함된 요청과 JWT 검증 헤더(해당하는 경우)가 백엔드에 전달됩니다.
응답이 백엔드에서 수신되면 API 게이트웨이가 응답을 호출자에게 반환하고 최종 타이밍 정보를 Trace로 전송합니다. Service Control API가 호출 포인트를 로깅하여 측정항목과 로그를 적절한 대상에 기록합니다.
[[["이해하기 쉬움","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)"],[[["\u003cp\u003eAPI Gateway is a fully managed system for API management, providing a secure, consistent REST API for backend services and handling authentication, monitoring, and logging.\u003c/p\u003e\n"],["\u003cp\u003eThe API provider defines APIs using OpenAPI specs, and API clients access these APIs without needing to know the backend implementation, while the client is only required to know the URL and the format of the API.\u003c/p\u003e\n"],["\u003cp\u003eService Control API handles API management rules at runtime, including API key validation, logging, and monitoring through methods like Check and Report.\u003c/p\u003e\n"],["\u003cp\u003eService Management API manages API configurations, such as creating the API config, sharing the API, and enabling or disabling the API in projects.\u003c/p\u003e\n"],["\u003cp\u003eWhen an API request is received, API Gateway routes the request to the correct backend service after performing authentication and validation, then returns the backend's response to the client, while also logging the call and sending metrics.\u003c/p\u003e\n"]]],[],null,["# API Gateway Architecture\n========================\n\nAPI Gateway is an API management system that provides management, monitoring, and authentication for your APIs. The components that make up API Gateway include:\n\n- **API Gateway**: for managing all aspects of a deployed API\n- **Service Control**: for applying API management rules\n- **Service Management**: for managing API configurations\n- **gcloud CLI**: for deploying and managing your APIs\n- **Google Cloud console**: for logging, monitoring and sharing\n\nArchitecture\n------------\n\nThe following is a high level diagram of the major components involved in API Gateway:\n\nIn this diagram:\n\n- **The API provider** is responsible for creating and deploying an API on API Gateway. Each API is defined by a file written as an OpenAPI 2.0 spec.\n\n The OpenAPI spec defines the publicly facing URL of the REST endpoint for the API, the backend service accessed by the API, and any other characteristics of the API such as authentication, data format, and response options.\n- **The API client** makes a REST request to an API hosted on API Gateway to access backend services. An API client can be any app capable of making a REST call, such as a browser, mobile app, or web app.\n\n The API client only needs to know the URL of the API, the request verb (such as `GET`, `PUT`, `POST`, `DELETE`),\n any authentication requirements, and the format of any data sent to or received from the API.\n\n The API client does not need to know anything about the backend implementation. In fact, a single API hosted on API Gateway can be configured to access different backends based on information passed in the request.\n\nAPI Gateway components\n----------------------\n\n### API Gateway\n\nAPI Gateway provides a fully managed, pay-per-use solution for hosting your APIs. API Gateway provide secure access to your backend services through a well-defined REST API that is consistent across all of your services, regardless of the service implementation.\n\nAPI Gateway is integrated with Google Cloud so that you can use the same development, monitoring, logging, and trace tools that you use with any other Google Cloud product.\n\nIf you are connecting to a backend service hosted outside of Google Cloud, you can still take advantage of all Google Cloud services, including the authentication and authorization services used to control access to your APIs.\n\n### Service Control API\n\n[Service Control API](https://cloud.google.com/service-control/) applies API management rules at runtime, such as API key authentication, monitoring, and logging. Service Control provides the following methods:\n\n- **Check**: verifies authentication and API keys, and indicates whether a call should be permitted\n- **Report**: notifies the systems of record for logging and monitoring\n\n### Service Management API\n\nYou use the [OpenAPI specification](/endpoints/docs/openapi/openapi-overview) to define your API. You then use the gcloud CLI to upload the OpenAPI spec to Service Management, which creates the API config. Other configuration-related tasks also happen here, such as sharing your API with other developers, enabling or disabling the API in different projects, and generating API keys.\n\n### gcloud CLI\n\nThe [gcloud CLI](https://cloud.google.com/sdk/docs) provides the [gcloud](/sdk/gcloud/reference) command-line tool that you can use to make calls to various Google Cloud services. You use the Google Cloud CLI to upload your OpenAPI spec, which creates the API config, and then to deploy the API config to API Gateway.\n\n### Cloud console\n\n[Google Cloud console](https://console.cloud.google.com/) is the graphical user interface for Google Cloud console. Use the Google Cloud console to expose monitoring and logging data recorded by Service Control, to configure authentication and authorization, and for developers to generate API keys to call the API.\n\nHandling an API request\n-----------------------\n\nIn an API configuration, there are two types of endpoints:\n\n- **API endpoint**: defines the publicly available endpoint that clients use to consume your APIs.\n- **Backend endpoint**: defines the endpoint that the API uses to connect to your backend service. Security settings, such as HTTP or HTTPS access, are defined by the implementation of the backend service.\n\nRequests to your API endpoint are passed to the backend endpoint, including any data passed as part of the request. Responses from the backend service, including any data returned by the service, are passed back to the client.\n\n### Request routing\n\nWhen a request is received:\n\n1. API Gateway creates a trace token for Cloud Trace.\n\n2. API Gateway matches the path of the incoming requests with the target API. After finding a matching route, API Gateway performs any authentication steps for the specified API.\n\n3. If JWT validation is necessary, API Gateway validates the authentication using the appropriate public key for the signer, and validates the audience field in the JWT. If an API key is required, API Gateway calls the Service Control API to validate the key.\n\n4. Service Control looks up the key to validate it, and ensures that the project associated with the key has enabled the API. If the key isn't valid or the project hasn't enabled the API, the call is rejected and it is logged via the Service Control API.\n\n5. If Service Control successfully validates the key, the request along with all original headers, plus a JWT validation header, if appropriate, is forwarded to the backend.\n\n6. When a response is received from the backend, API Gateway returns the response to the caller and sends the final timing information to Trace. The call points are logged by the Service Control API, which then writes metrics and logs to their appropriate destinations.\n\nWhat's next\n-----------\n\n- [API Gateway Deployment Model](/api-gateway/docs/deployment-model)"]]