HTTP 연결 유지 또는 HTTP 연결 재사용이라고도 하는 HTTP 영구 연결은 모든 요청/응답 쌍에 대해 새로운 연결을 여는 대신 단일 TCP 연결을 통해 여러 HTTP 요청/응답을 전송 및 수신할 수 있다는 개념입니다.
Apigee는 백엔드 서비스와 통신하기 위해 영구 연결을 사용합니다. 연결은 기본적으로 60초 동안 유지됩니다. 즉, 연결 풀에서 연결이 60초 이상 유휴 상태이면 연결이 종료됩니다.
연결 유지 시간 제한 기간은 API 프록시의 TargetEndpoint 구성에 지정된 keepalive.timeout.millis 속성을 통해 구성할 수 있습니다. 예를 들어 TargetEndpoint의 특정 백엔드 서비스에 대한 연결 유지 기간을 30초로 설정할 수 있습니다.
아래 예시에서는 TargetEndpoint 구성에서 keepalive.timeout.millis가 30초로 설정됩니다.
위 예시에서 keepalive.timeout.millis는 API 프록시의 특정 백엔드 서비스에 대한 연결 유지 동작을 제어합니다. 또한 모든 프록시의 모든 백엔드 서비스에 대한 연결 유지 동작을 제어하는 속성도 있습니다. HTTPTransport.keepalive.timeout.millis는 메시지 프로세서 구성요소에서 구성할 수 있습니다. 이 속성도 기본값이 60초입니다. 이 속성을 수정하면 Apigee와 모든 API 프록시의 모든 백엔드 서비스 간 연결 유지 작업에 영향을 줍니다.
안티패턴
특정 API 프록시의 TargetEndpoint 구성에서 keepalive.timeout.millis 속성을 0으로 설정하거나 메시지 프로세서에서 HTTPTransport.keepalive.timeout.millis를 0으로 설정하여 영구(연결 유지) 연결을 사용 중지하는 것은 성능에 영향을 미치므로 권하지 않습니다.
아래 예시에서 TargetEndpoint 구성은 keepalive.timeout.millis를 0으로 설정하여 특정 백엔드 서비스에 대한 영구(연결 유지) 연결을 사용 중지합니다.
하나 이상의 백엔드 서비스에 대해 연결 유지를 사용 중지하면 Apigee는 대상 백엔드 서비스에 대한 새로운 요청마다 새로운 연결을 열어야 합니다. 백엔드가 HTTPS이면 Apigee는 새 요청마다 SSL 핸드셰이크도 수행하여 전체 API 요청의 지연 시간이 늘어납니다.
영향
Apigee가 새 연결을 열고 모든 새 요청마다 SSL 핸드셰이크를 수행해야 하므로 API 요청의 전체 응답 시간이 증가합니다.
시스템에 대한 연결을 해제하는 데 시간이 다소 걸리므로 트래픽 급증 상황에서는 연결이 소진될 수 있습니다.
권장사항
백엔드 서비스는 HTTP 1.1 표준에 따라 HTTP 영구 연결을 반영하고 처리해야 합니다.
백엔드 서비스는 영구(연결 유지) 연결을 처리할 수 있는 경우 Connection:keep-alive 헤더로 응답해야 합니다.
백엔드 서비스는 영구 연결을 처리할 수 없는 경우에도 Connection:close 헤더로 응답해야 합니다.
이 패턴을 구현하면 Apigee가 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-05(UTC)"],[[["\u003cp\u003eApigee utilizes persistent connections for backend service communication, with a default 60-second keep-alive timeout for idle connections.\u003c/p\u003e\n"],["\u003cp\u003eThe keep-alive timeout can be customized for specific backend services using the \u003ccode\u003ekeepalive.timeout.millis\u003c/code\u003e property in the TargetEndpoint configuration.\u003c/p\u003e\n"],["\u003cp\u003eDisabling persistent connections by setting \u003ccode\u003ekeepalive.timeout.millis\u003c/code\u003e to 0 is not recommended, as it increases API request latency and can exhaust connections under high traffic.\u003c/p\u003e\n"],["\u003cp\u003eBackend services should adhere to HTTP 1.1 standards by using \u003ccode\u003eConnection:keep-alive\u003c/code\u003e or \u003ccode\u003eConnection:close\u003c/code\u003e headers to manage persistent connection behavior.\u003c/p\u003e\n"],["\u003cp\u003eApigee offers different ways to connect to backend services such as TargetEndpoint, ServiceCallout policy, JavaScript policy or JavaCallout policy.\u003c/p\u003e\n"]]],[],null,["# Antipattern: Disable HTTP persistent (reusable keep-alive) connections\n\n*You're viewing **Apigee** and **Apigee hybrid** documentation.\nView [Apigee Edge](https://docs.apigee.com/api-platform/antipatterns/disable-persistent-connections) documentation.*\n\n\nAn API proxy is an interface for client applications used to connect with backend services.\nApigee provides multiple ways to connect to backend services through an API proxy:\n\n- [TargetEndpoint](/apigee/docs/api-platform/fundamentals/understanding-apis-and-api-proxies) to connect to any HTTP/HTTPs, NodeJS, or Hosted Target services.\n- [ServiceCallout policy](/apigee/docs/api-platform/reference/policies/service-callout-policy) to invoke any external service pre- or post- invocation of the target server in [TargetEndpoint](/apigee/docs/api-platform/fundamentals/understanding-apis-and-api-proxies).\n- Custom code added to the [JavaScript policy](/apigee/docs/api-platform/reference/policies/javascript-policy) or [JavaCallout policy](/apigee/docs/api-platform/reference/policies/java-callout-policy) to connect to backend services.\n\n### Persistent Connections\n\n\n[HTTP persistent connection](https://en.wikipedia.org/wiki/HTTP_persistent_connection),\nalso called HTTP keep-alive or HTTP connection reuse, is a concept that allows a single\n[TCP](https://en.wikipedia.org/wiki/Transmission_Control_Protocol) connection to send and\nreceive multiple [HTTP requests](https://en.wikipedia.org/wiki/HTTP_request)/responses,\ninstead of opening a new connection for every request/response pair.\n\n\nApigee uses persistent connection for communicating with backend services. A connection stays\nalive for 60 seconds by default. That is, if a connection is idle in the connection pool for\nmore than 60 seconds, then the connection closes.\n\n\nThe keep alive timeout period is configurable through a property named `keepalive.timeout.millis`,\nspecified in the TargetEndpoint configuration of an API proxy. For example, the keep alive\ntime period can be set to 30 seconds for a specific backend service in the TargetEndpoint.\n\n\nIn the example below, the `keepalive.timeout.millis` is set to 30 seconds in the TargetEndpoint\nconfiguration: \n\n```world-of-warcraft-toc\n\u003c!-- /antipatterns/examples/disable-persistent-connections-1.xml --\u003e\n\u003cTargetEndpoint name=\"default\"\u003e\n \u003cHTTPTargetConnection\u003e\n \u003cURL\u003ehttp://mocktarget.apigee.net\u003c/URL\u003e\n \u003cProperties\u003e\n \u003cProperty name=\"keepalive.timeout.millis\"\u003e30000\u003c/Property\u003e\n \u003c/Properties\u003e\n \u003c/HTTPTargetConnection\u003eDisable HTTP persistent (Reusable keep-alive) connections\n\u003c/TargetEndpoint\u003e\n```\n\n\nIn the example above, `keepalive.timeout.millis` controls the keep alive behavior for a\nspecific backend service in an API proxy. There is also a property that controls keep alive behavior\nfor all backend services in all proxies. The `HTTPTransport.keepalive.timeout.millis`\nis configurable in the Message Processor component. This property also has a default value of 60\nseconds. Making any modifications to this property affects the keep alive connection behavior between\nApigee and all the backend services in all the API proxies.\n\nAntipattern\n-----------\n\n\nDisabling persistent (keep alive) connections by setting the property `keepalive.timeout.millis`\nto 0 in the TargetEndpoint configuration of a specific API Proxy or setting the\n`HTTPTransport.keepalive.timeout.millis` to 0 on Message Processors is not recommended as\nit will impact performance.\n\n\nIn the example below, the TargetEndpoint configuration disables persistent (keep alive) connections\nfor a specific backend service by setting `keepalive.timeout.millis` to 0: \n\n```world-of-warcraft-toc\n\u003c!-- /antipatterns/examples/disable-persistent-connections-2.xml --\u003e\n\u003cTargetEndpoint name=\"default\"\u003e\n \u003cHTTPTargetConnection\u003e\n \u003cURL\u003ehttp://mocktarget.apigee.net\u003c/URL\u003e\n \u003cProperties\u003e\n \u003cProperty name=\"keepalive.timeout.millis\"\u003e0\u003c/Property\u003e\n \u003c/Properties\u003e\n \u003c/HTTPTargetConnection\u003e\n\u003c/TargetEndpoint\u003e\n```\n\n\nIf keep alive connections are disabled for one or more backend services, then Apigee must open a\nnew connection for each new request to the target backend service(s). If the backend is HTTPs,\nApigee will also perform SSL handshake for each new request, adding to the overall\nlatency of API requests.\n\nImpact\n------\n\n- Increases the overall response time of API requests as Apigee must open a new connection and perform SSL handshake for every new request.\n- Connections may be exhausted under high traffic conditions, as it takes some time to release connections back to the system.\n\nBest Practice\n-------------\n\n- Backend services should honor and handle HTTP persistent connection in accordance with HTTP 1.1 standards.\n- Backend services should respond with a `Connection:keep-alive` header if they are able to handle persistent (keep alive) connections.\n- Backend services should respond with a `Connection:close` header if they are unable to handle persistent connections.\n\n\nImplementing this pattern will ensure that Apigee can automatically handle persistent or non-persistent\nconnection with backend services, without requiring changes to the API proxy.\n\nFurther reading\n---------------\n\n- [HTTP persistent connections](https://en.wikipedia.org/wiki/HTTP_persistent_connection)\n- [Keep-Alive](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Keep-Alive)\n- [Endpoint Properties Reference](/apigee/docs/api-platform/reference/endpoint-properties-reference)"]]