Skip to content

Commit

Permalink
web socket 내용 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
greeng00se committed Sep 7, 2023
1 parent 5e3dda5 commit 5d71d2e
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions blog/2023-2/2023-06-26-WebSocket.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,22 @@ tags: [WebSocket]

### 웹소켓 등장 배경

웹소켓이 등장하기 이전, 실시간성을 보장하기 위해 Polling, Streaming 같은 기술을 사용했어야 했다.
웹소켓이 등장하기 이전, 실시간성을 보장하기 위해 Polling, Long polling, Streaming 같은 기술을 사용했어야 했다.
이는 실시간성이나 양방향성을 만족시키지 못했고, HTTP를 이용하기 때문에 과도한 오버헤드가 발생했다.

:::note polling, long polling, streaming

Polling: 주기적으로 서버에 요청을 보내 수신할 정보가 있는지 확인하는 방법
- 서버에서 보낼 내용이 없어도 클라이언트는 알 수 없다.
- 계속해서 요청을 보내 확인을 해야하기 때문에 서버에 불필요한 부하를 줘야 한다.

Long Polling: 클라이언트의 요청에 대해 응답을 보내지 않고 있다가 이벤트가 발생했을때 응답하는 방법
- 폴링 방식보다 서버에 적은 부하를 줄 수 있지만, 이벤트의 텀이 짧으면 폴링과 차이가 없어진다.

Streaming: 클라이언트가 request를 보내면 커넥션을 맺고, 이 커넥션을 유지하면서 서버가 계속 데이터를 보내는 방법
- 클라이언트가 서버에 요청을 하고 싶다면 새로운 커넥션을 맺어야 한다.
:::

### 웹소켓의 동작

```mermaid
Expand Down Expand Up @@ -73,7 +86,7 @@ Sec-WebSocket-Protocol: v10.stomp

### 참고 자료

https://datatracker.ietf.org/doc/html/rfc6455
https://datatracker.ietf.org/doc/html/rfc6455
https://developer.mozilla.org/ko/docs/Web/API/WebSockets_API/Writing_WebSocket_client_applications
https://developer.mozilla.org/ko/docs/Web/API/WebSockets_API/Writing_WebSocket_servers
https://docs.spring.io/spring-framework/reference/web/websocket.html

0 comments on commit 5d71d2e

Please sign in to comment.