Web
[WEB] HTTP/1.1 이랑 HTTP/2 비교 해 보자!
hoonylab
2025. 4. 21. 14:46
728x90
반응형
✅ HTTP/1.1 vs HTTP/2 비교
항목 | HTTP/1.1 | HTTP/2 |
---|---|---|
멀티플렉싱 | 불가능 | 가능 |
헤더 압축 | 없음 | 있음 (HPACK) |
요청 순서 | 순차 처리 | 병렬 처리 |
서버 푸시 | 없음 | 가능 |
연결 수 | 다수 필요 | 하나의 연결로 처리 |
🌐 클라이언트: Axios 예제
📦 HTTP/1.1 기본 사용
axios.get('http://localhost:8080/api/data')
.then(response => {
console.log(response.data);
});
⚙️ HTTP/2 사용 (Node.js 환경)
import axios from 'axios';
import http2 from 'http2-wrapper';
axios.get('https://example.com/api', {
transport: http2
}).then(res => {
console.log(res.data);
});
🧩 서버: Spring Boot 설정
📌 기본 HTTP/1.1 설정
@RestController
public class MyController {
@GetMapping("/api/data")
public String getData() {
return "HTTP/1.1 response";
}
}
🔧 HTTP/2 활성화 설정
server:
http2:
enabled: true
ssl:
key-store: classpath:keystore.p12
key-store-password: changeit
key-store-type: PKCS12
🔖 추천 태그
- #HTTP2
- #SpringBoot
- #Axios
- #웹성능
- #프론트백엔드
728x90
반응형