SlideShare a Scribd company logo
🍿 Unlocking Real-Time
Web Applications
🏆 The Challenge
Let’s meet
Rodrigo
Rodrigo works on the frontend side of
the complex e-commerce platform.
Backend team just deployed new feature:
the new API endpoint which allows
to check status of the order.
Backend team just deployed new feature:
the new API endpoint which allows
to check status of the order.
Today is Friday, and there is
urgent business requirement
to display order status on the frontend side.
Rodrigo was working on the new feature a whole day
and at 4 PM deployed changes to production.
Rodrigo was working on the new feature a whole day
and at 4 PM deployed changes to production.
Deploy was successful and Rodrigo can
go home or 🍺
Rodrigo was working on the new feature a whole day
and at 4 PM deployed changes to production.
Deploy was successful and Rodrigo can
go home or 🍺
Frontend Backend
Request
Response
Frontend
Request
Response
Backend
🤯 The Problem
Backend is not responding immediately the
status of the order because there are plenty of
operations to process.
Correct status can be retrieved
after few milliseconds.
👨💻 Rodrigo’s Solution
Unlocking Realtime Web Applications  - 4Developers Katowice 2023
Unlocking Realtime Web Applications  - 4Developers Katowice 2023
Unlocking Realtime Web Applications  - 4Developers Katowice 2023
💩
What could
go wrong?
What could
go wrong?
We’ll
refactor
oneway
What could
go wrong?
We’ll
refactor
oneway
#yolodevelopment
Backend is not responding immediately the
status of the order because there are plenty of
operations to process.
Backend is not responding immediately the
status of the order because there are plenty of
operations to process.
Unfortunately there was a bug in the infrastructure.
During the weekend tra
ffi
c increased and backend
wasn’t able respond with valid status.
Frontend
Request
Response
Backend
Order Status Microservice
😭 Monday
Unlocking Realtime Web Applications  - 4Developers Katowice 2023
Customers who created new orders didn’t get status
Moreover there were thousands of requests to
backend in users’ browsers tabs
Unlocking Realtime Web Applications  - 4Developers Katowice 2023
¡Hola Amigos!
@PatrykOmiotek
Use the right tools
for speci
fi
c problems…
…to create
elegant solutions
🔓 Unlock Realtime-apps
🙋 What are Realtime apps?
This is done using a variety of technologies, such
as WebSockets, server-sent events,
and long polling.
Real-time web applications are applications that
allow users to receive updates from the server
without having to manually refresh the page.
🧩 Use cases
1. Chat and messages
2. Social media updates
3. News feeds
4. Noti
fi
cations and alerts
5. Collaborative editing tools
6. Stock tickers
7. Real-time gaming
😏 Standard way
Traditionally, a web page has to send a request to the server to
receive new data; that is, the page requests data
from the server.
With server-sent events, it's possible for a server to send new
data to a web page at any time, by pushing messages
to the web page.
These incoming messages can be treated as Events + data
inside the web page.
🎯 What are Server-Sent Events?
Let’s talk about what SSE is not
🥊 WebSockets vs SSE
🥊 WebSockets vs SSE
Eo eo i mem z Freddy
Eo eo i mem z Freddy
Server
Eo eo i mem z Freddy
Server
Eeeooo
Eo eo i mem z Freddy
Server
Eeeooo
Client
Eo eo i mem z Freddy
Server
Eeeooo
Client
Client
Eo eo i mem z Freddy
Server
Eeeooo
Client
Client
Client
Eo eo i mem z Freddy
Server
Eeeooo
Client
Client
Client
Client
Eo eo i mem z Freddy
Server
Eeeooo
Client
Client
Client
Client
Eeeooo
Eo eo i mem z Freddy
Server
Client
Client
Client
Client
Eeeooo
Eeeooo
Eeeooo
Eeeooo
Web Sockets
Eeeooo
Eo eo i mem z Freddy
Server
Client
Client
Client
Client
🤐
🤐
🤐 Eeeooo
🤐
SSE
Eo eo i mem z Freddy
Server
Eeeooo
Client
Client
Client
Client
SSE
Feature WebSockets SSE
Communication channel Full-duplex One-way
Protocol TCP HTTP
Bidirectional communication Yes No
Binary data support Yes No
Latency Low Medium
Scalability High High
Complexity Medium Low
Feature Long polling SSE
Communication channel Bidirectional One-way
Protocol HTTP HTTP
Bidirectional communication Yes No
Binary data support Yes No
Latency Medium Low
Scalability Medium High
Complexity Low Medium
Feature Web Sockets Long polling SSE
Communication channel Full-duplex Bidirectional One-way
Protocol TCP HTTP HTTP
Bidirectional communication Yes Yes No
Binary data support Yes Yes No
Latency Low Medium Low
Scalability High Medium High
Complexity Medium Low Medium
🤓 OK, Show me the code!
Part 1/2
⌨ Server implementation
Unlocking Realtime Web Applications  - 4Developers Katowice 2023
Unlocking Realtime Web Applications  - 4Developers Katowice 2023
Unlocking Realtime Web Applications  - 4Developers Katowice 2023
Unlocking Realtime Web Applications  - 4Developers Katowice 2023
Unlocking Realtime Web Applications  - 4Developers Katowice 2023
Unlocking Realtime Web Applications  - 4Developers Katowice 2023
Unlocking Realtime Web Applications  - 4Developers Katowice 2023
Unlocking Realtime Web Applications  - 4Developers Katowice 2023
Unlocking Realtime Web Applications  - 4Developers Katowice 2023
Unlocking Realtime Web Applications  - 4Developers Katowice 2023
Unlocking Realtime Web Applications  - 4Developers Katowice 2023
Unlocking Realtime Web Applications  - 4Developers Katowice 2023
Unlocking Realtime Web Applications  - 4Developers Katowice 2023
Unlocking Realtime Web Applications  - 4Developers Katowice 2023
Part 2/2
🎨 Frontend implementation
🧵 EventSource
An EventSource instance opens
a persistent connection
to an HTTP server,
which sends events in text/event-stream format.
Unlocking Realtime Web Applications  - 4Developers Katowice 2023
Unlocking Realtime Web Applications  - 4Developers Katowice 2023
Unlocking Realtime Web Applications  - 4Developers Katowice 2023
Unlocking Realtime Web Applications  - 4Developers Katowice 2023
Unlocking Realtime Web Applications  - 4Developers Katowice 2023
✅ SSE Advantages
• Simple to implement and understand
• Built on top of HTTP
• Error handling via auto-reconnect comes built-in
• Supported by all major browsers
• Scalable, as the server can send events to many
clients simultaneously.
❌ SSE Limitations
• One-way communication (server to client only).
• Not supported natively in all browsers (Microsoft Edge/IE v78
and earlier)
• When used over HTTP 1.1 there’s a limit of 6 open SSE
connections per browser, but when SSE is used over HTTP/2
the maximum number of simultaneous HTTP streams is
negotiated between the server and the client (defaults to 100)
• Overhead compared to WebSockets for certain scenarios
• No support for binary data (only UTF-8 encoded text)
🐞 Error Handling
and
Connection Management
Source: https://www.aklivity.io/post/a-primer-on-server-sent-events-sse
• Handling connection losses and re-establishing
connections.
• Listening to SSE error events in React.
🏃 Optimizations
and
Best Practices
• Throttling messages for performance
• Using a backoff strategy for reconnections
• Closing connections when not needed
▶ Other use cases
Let’s assume Rodrigo is building
AI image processing platform
Let’s assume Rodrigo is building
AI image processing platform
or Real-time noti
fi
cations
or Live news or sport scores.
or Collaborative tools (e.g., shared document editing).
Let’s assume Rodrigo is building
AI image processing platform
or Real-time noti
fi
cations
or Live news or sport scores.
or Collaborative tools (e.g., shared document editing).
because he wants to become
Señor AI Cloud Blockchain Developer ;)
Unlocking Realtime Web Applications  - 4Developers Katowice 2023
🧮 When operation will complete?
🧮 When operation will complete?
🧮 When operation will complete?
🤷
👌 Tips
🙅 CORS
📖 Headers
🎸 Design, implement, refactor, repeat
✨ State manager
✨ State manager
👨💻 Code
🌈 Conclusion
Unlocking Realtime Web Applications  - 4Developers Katowice 2023
You can catch me here:
🙏 Thank you
Plan na dziś
• Kodujemy bibliotekę komponentów
• MEWA (Modern and Ef
fi
cient Web Applications)

More Related Content

Similar to Unlocking Realtime Web Applications - 4Developers Katowice 2023 (20)

PDF
Server-Sent Events (real-time HTTP push for HTML5 browsers)
yay w00t
 
PDF
What is a WebSocket? Real-Time Communication in Applications
Inexture Solutions
 
KEY
Message in a Bottle
Zohar Arad
 
PDF
Server Sent Events
Mohanad Obaid
 
PDF
Role of Server-Sent Events in Reactive Programming
Covalensedigital
 
PDF
HTML5 Server Sent Events/JSF JAX 2011 Conference
Roger Kitain
 
PPTX
Multi-Process JavaScript Architectures
Mark Trostler
 
PDF
Impromptu orchestra: HTTP/2 and Reactive Streams (DevoxxUK)
Berwout De Vries Robles
 
PPTX
Fight empire-html5
Bhakti Mehta
 
PDF
Con fess 2013-sse-websockets-json-bhakti
Bhakti Mehta
 
PDF
Building Web APIs that Scale
Salesforce Developers
 
PPTX
Difference between Client Polling vs Server Push vs Websocket vs Long Polling
jeetendra mandal
 
PDF
WebHooks in 10 Minutes
Jeff Lindsay
 
PPTX
Browser APIs for data exchange: types and application
Pavel Klimiankou
 
PDF
Using Communication and Messaging API in the HTML5 World
Gil Fink
 
PDF
WebSocket in Enterprise Applications 2015
Pavel Bucek
 
PPTX
Real-time ASP.NET with SignalR
Alexander Konduforov
 
PPSX
SignalR With ASP.Net part1
Esraa Ammar
 
PDF
Introduction to Node.js
Richard Lee
 
Server-Sent Events (real-time HTTP push for HTML5 browsers)
yay w00t
 
What is a WebSocket? Real-Time Communication in Applications
Inexture Solutions
 
Message in a Bottle
Zohar Arad
 
Server Sent Events
Mohanad Obaid
 
Role of Server-Sent Events in Reactive Programming
Covalensedigital
 
HTML5 Server Sent Events/JSF JAX 2011 Conference
Roger Kitain
 
Multi-Process JavaScript Architectures
Mark Trostler
 
Impromptu orchestra: HTTP/2 and Reactive Streams (DevoxxUK)
Berwout De Vries Robles
 
Fight empire-html5
Bhakti Mehta
 
Con fess 2013-sse-websockets-json-bhakti
Bhakti Mehta
 
Building Web APIs that Scale
Salesforce Developers
 
Difference between Client Polling vs Server Push vs Websocket vs Long Polling
jeetendra mandal
 
WebHooks in 10 Minutes
Jeff Lindsay
 
Browser APIs for data exchange: types and application
Pavel Klimiankou
 
Using Communication and Messaging API in the HTML5 World
Gil Fink
 
WebSocket in Enterprise Applications 2015
Pavel Bucek
 
Real-time ASP.NET with SignalR
Alexander Konduforov
 
SignalR With ASP.Net part1
Esraa Ammar
 
Introduction to Node.js
Richard Lee
 

More from Patryk Omiotek (6)

PDF
TensorFlow for beginners
Patryk Omiotek
 
PDF
Docker how to
Patryk Omiotek
 
PDF
Web crawlers part-2-20161104
Patryk Omiotek
 
PDF
How the Internet of Things will change our lives?
Patryk Omiotek
 
PDF
How to build own IoT Platform
Patryk Omiotek
 
ODP
WordpUp Lublin #1
Patryk Omiotek
 
TensorFlow for beginners
Patryk Omiotek
 
Docker how to
Patryk Omiotek
 
Web crawlers part-2-20161104
Patryk Omiotek
 
How the Internet of Things will change our lives?
Patryk Omiotek
 
How to build own IoT Platform
Patryk Omiotek
 
WordpUp Lublin #1
Patryk Omiotek
 
Ad

Recently uploaded (20)

PDF
IoT - Unit 2 (Internet of Things-Concepts) - PPT.pdf
dipakraut82
 
PDF
monopile foundation seminar topic for civil engineering students
Ahina5
 
PPTX
Hashing Introduction , hash functions and techniques
sailajam21
 
PDF
PRIZ Academy - Change Flow Thinking Master Change with Confidence.pdf
PRIZ Guru
 
DOCX
8th International Conference on Electrical Engineering (ELEN 2025)
elelijjournal653
 
PDF
Book.pdf01_Intro.ppt algorithm for preperation stu used
archu26
 
PDF
MOBILE AND WEB BASED REMOTE BUSINESS MONITORING SYSTEM
ijait
 
PDF
Ethics and Trustworthy AI in Healthcare – Governing Sensitive Data, Profiling...
AlqualsaDIResearchGr
 
PPTX
REINFORCEMENT AS CONSTRUCTION MATERIALS.pptx
mohaiminulhaquesami
 
PDF
Water Design_Manual_2005. KENYA FOR WASTER SUPPLY AND SEWERAGE
DancanNgutuku
 
PDF
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
PDF
UNIT-4-FEEDBACK AMPLIFIERS AND OSCILLATORS (1).pdf
Sridhar191373
 
PDF
ARC--BUILDING-UTILITIES-2-PART-2 (1).pdf
IzzyBaniquedBusto
 
PPTX
UNIT DAA PPT cover all topics 2021 regulation
archu26
 
PDF
Unified_Cloud_Comm_Presentation anil singh ppt
anilsingh298751
 
PDF
Additional Information in midterm CPE024 (1).pdf
abolisojoy
 
PPTX
Thermal runway and thermal stability.pptx
godow93766
 
PDF
Statistical Data Analysis Using SPSS Software
shrikrishna kesharwani
 
PDF
A presentation on the Urban Heat Island Effect
studyfor7hrs
 
PPTX
Introduction to Neural Networks and Perceptron Learning Algorithm.pptx
Kayalvizhi A
 
IoT - Unit 2 (Internet of Things-Concepts) - PPT.pdf
dipakraut82
 
monopile foundation seminar topic for civil engineering students
Ahina5
 
Hashing Introduction , hash functions and techniques
sailajam21
 
PRIZ Academy - Change Flow Thinking Master Change with Confidence.pdf
PRIZ Guru
 
8th International Conference on Electrical Engineering (ELEN 2025)
elelijjournal653
 
Book.pdf01_Intro.ppt algorithm for preperation stu used
archu26
 
MOBILE AND WEB BASED REMOTE BUSINESS MONITORING SYSTEM
ijait
 
Ethics and Trustworthy AI in Healthcare – Governing Sensitive Data, Profiling...
AlqualsaDIResearchGr
 
REINFORCEMENT AS CONSTRUCTION MATERIALS.pptx
mohaiminulhaquesami
 
Water Design_Manual_2005. KENYA FOR WASTER SUPPLY AND SEWERAGE
DancanNgutuku
 
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
UNIT-4-FEEDBACK AMPLIFIERS AND OSCILLATORS (1).pdf
Sridhar191373
 
ARC--BUILDING-UTILITIES-2-PART-2 (1).pdf
IzzyBaniquedBusto
 
UNIT DAA PPT cover all topics 2021 regulation
archu26
 
Unified_Cloud_Comm_Presentation anil singh ppt
anilsingh298751
 
Additional Information in midterm CPE024 (1).pdf
abolisojoy
 
Thermal runway and thermal stability.pptx
godow93766
 
Statistical Data Analysis Using SPSS Software
shrikrishna kesharwani
 
A presentation on the Urban Heat Island Effect
studyfor7hrs
 
Introduction to Neural Networks and Perceptron Learning Algorithm.pptx
Kayalvizhi A
 
Ad

Unlocking Realtime Web Applications - 4Developers Katowice 2023