개발/spring
[websocket] REST-http vs websocket
방푸린
2022. 6. 10. 15:37
반응형
websocket vs RESTful http
- 공통점
- tcp layer
- OSI 7계층 중 최상위 application layer
- TLS security(https, wss); 443 port
- 차이점
- websocket
- bi-directional: 양방향 통신
- full-duplex: 서버와 클라이언트가 동시에 독립적으로 상대에게 이야기할 수있음
- event based
- stateful protocol: 한쪽에서 끊을때까지 계속 연결된 상태
- persistent single TCP connection: websocket connection lifecycle동안 하나의 tcp connection에서 통신
- ws:// wss://
- 리얼타임/게임/채팅과 같이 실시간 업데이트, 지속적인 데이터를 받아야 하는 곳
- RESTful http
- uni-directional: 한번에 한 방향으로 통신
- request-response based
- stateless protocol
- non persistent connection: 요청하고 끊고 응답주고 끊고, 10개의 요청을 보내면 10개의 connection이 생김
- http://, https://
- 과거 데이터, 데이터를 한번만 받아도 되는 곳
- websocket
앞으로 아래 두 글을 바탕으로 샘플 websocket 프로젝트를 만들고 변형한다. websocket과 webflux는 사상이 비슷(event driven)한 친구라 이번 기회에 두 스택을 같이 사용해보려고 한다.
환경: java17, springboot2.5.6 / webflux / mongo on docker
Web on Reactive Stack
The original web framework included in the Spring Framework, Spring Web MVC, was purpose-built for the Servlet API and Servlet containers. The reactive-stack web framework, Spring WebFlux, was added later in version 5.0. It is fully non-blocking, supports
docs.spring.io
https://www.baeldung.com/spring-5-reactive-websockets
Reactive WebSockets with Spring 5 | Baeldung
A quick and practical example of Spring Framework 5 Reactive WebSockets API.
www.baeldung.com
728x90
반응형