[[["わかりやすい","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-08-21 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,["*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\nPersistent 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\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- 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- 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- [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)"]]