Keep connections warm and cheap
Network setup can cost 60–120 ms.
Reuse connections and cut TLS work.
Java 17 HttpClient:
var client = HttpClient.newBuilder()
.version(HttpClient.Version.HTTP_2) // multiplex, fewer sockets
.connectTimeout(Duration.ofMillis(200))
.followRedirects(HttpClient.Redirect.NEVER)
.sslParameters(new SSLParameters()) // allow session resumption
.build();
// Example call; reuse client across requests
var req = HttpRequest.newBuilder(URI.create("https://api.internal/users/42"))
.header("Connection", "keep-alive")
.GET().build();
var res = client.send(req, HttpResponse.BodyHandlers.ofString());
HTTP/2 with keep-alive and TLS session resumption trimmed ~40–70 ms on coldish paths and stabilized p95.
Alternative: If the client sits behind a gateway, enable connection pools there and pin upstream IPs to tame DNS variance.
참고 - 상세 링크
'JAVA > Java 일반' 카테고리의 다른 글
JAVA 21 설치 정리(Amazon Corretto JDK 21 설치) (0) | 2023.11.14 |
---|---|
Google Play store에 유저 구매 취소 리스트 가져오는 소스 (0) | 2023.10.26 |
ZGC 간략한 정리 (0) | 2023.08.18 |
Java JIT 컴파일러 옵션 (0) | 2023.05.19 |
java잡담: java virtual thread의 draft(2023/03/06 created) (0) | 2023.03.23 |