Server Sent Events (One Way HTTP protocol)
Before HTML5, there was no standardized technology for server push in HTML, so when real-time information needed to be received on the web, external plugins or Ajax polling techniques that mimicked server push were used.
- WebSocket is mainly used where real-time communication is needed
- SSE establishes a persistent HTTP connection and allows the server to push events to the client; it does not rely on periodic polling (e.g., every 3 seconds).
- Serverless is hard
WebSocket is not always better than SSE. For cases like chat or games where users need to react immediately to server data, WebSocket would be more efficient. However, in many cases, client-side reactions are not necessary.
SSE also has advantages in terms of browser support. When a browser doesn't support WebSocket, the server must implement a separate fallback protocol. On the other hand, since SSE is a client-side technology, if the browser supports JavaScript, it can be implemented using polyfills without making the server-side implementation more complex.
SSE Server
config sse
Notify
register sse client
When sending data, you must add \n\n at the end. The \n\n signals the end of the event stream
SSE Client
Server-Sent Events (SSE) Are Underrated
Most developers know about WebSockets, but Server-Sent Events (SSE) offer a simpler, often overlooked alternative that deserves more attention
https://igorstechnoclub.com/server-sent-events-sse-are-underrated/

SSE를 이용한 실시간 웹앱
HTML5가 등장하기 전까지는 HTML에 서버 푸시를 위한 표준화된 기술이 없었기 때문에 웹에서 실시간 정보를 받아와야 할 때 외부 플러그인을 이용하거나 서버 푸시를 흉내 낸 Ajax 폴링(polling) 기법 등을 사용했습니다. 하지만 플러그인 종속적인 웹은 해당 플러그인을 설치해야 한다는 불편함이 있으며 폴링처럼 주기적인 요청을 통한 구현은 쓸모없는 요청의 발생으로 인한 대역폭의 낭비가 불가피하였습니다.
https://spoqa.github.io/2014/01/20/sse.html

Server-Sent Events: the alternative to WebSockets you should be using
When developing real-time web applications, WebSockets might be the first thing that come to your mind. However, Server Sent Events (SSE) are a simpler alternative that is often superior. Recently I have been curious about the best way to implement a real-time web application.
https://germano.dev/sse-websockets/


Seonglae Cho