Chapter 7 Notes Final
Chapter 7 Notes Final
Benefits:
• Ensures real-time consistency between devices.
• Helps in collaborative work (e.g., Google Docs).
• Supports offline to online data updates.
Drawbacks:
• Real-time sync can consume more network resources.
• Risk of data conflicts when changes happen at the same time.
• Needs proper error handling and conflict resolution.
(ii) Remote Method Invocation (RMI) and Remote Procedure Call (RPC)
Definition:
• RPC allows a program to call a function on a remote server as if it were local.
• RMI is similar but used in Java, where one object can call another object
remotely.
Benefits:
• Makes distributed computing easier.
• Hides the complexity of network communication.
• Encourages modular programming.
Drawbacks:
• Can be slow due to network delay.
• Security risks if exposed to public networks.
• Error handling is more complex than local calls.
(iii) Simple Messaging
Definition:
Simple messaging is the exchange of data as messages using standard formats (like
JSON, XML) through HTTP or MQTT.
Benefits:
• Easy to implement and understand.
• Works well for lightweight data transfer.
• Good for mobile and IoT applications.
Drawbacks:
• Not suitable for large or real-time data.
• Doesn’t guarantee message delivery unless handled manually.
• Can cause delays if using polling.
(iv) Publish-Subscribe (Pub/Sub)
Definition:
In Pub/Sub, publishers send messages to a central system, and subscribers get
updates based on topics they’re interested in.
Benefits:
• Highly scalable for large systems.
• Loosely coupled – publisher and subscriber don’t need to know each other.
• Supports real-time data distribution.
Drawbacks:
• Complex to implement if there are many topics/subscribers.
• Harder to debug and trace errors.
• Needs a reliable message broker (like Kafka, RabbitMQ).
3) Different protocols used to send data to the client
Connection
Protocol Direction Best Use-Case Key Limitation
Type
One-way
Stateless HTTP Server-to-server No continuous
Webhooks (event-
POST notifications streaming
triggered)
One-way Semi-
Basic real-time
Long Polling (client- persistent High server load
chat, updates
initiated) HTTP
One-way
Persistent Live feeds, Text-only, limited
SSE (server-
HTTP notifications mobile support
initiated)
Webhooks: Trigger callbacks via HTTP POSTs to client endpoints upon specific
events. Lightweight and good for server-to-server communication but lacks
reliability guarantees.
- HTTP Long Polling: Maintains a semi-persistent connection. The client sends a
request, and the server holds it until data is available or a timeout occurs. It
emulates real-time communication but isn't as efficient.
- Server-Sent Events (SSE): An HTTP-based protocol that enables the server to push
events to the client over a persistent connection. Ideal for one-way communication
like notifications.
- WebSockets: Establishes a full-duplex TCP connection after an HTTP handshake.
Allows bidirectional communication and is optimal for applications requiring
continuous interaction, such as gaming or chat systems.
4) explain
(i) web hooks
(ii) http long polling
(iii) server-sent events
(iv) web sockets
(i) Webhooks
Webhooks are automated HTTP callbacks triggered by specific events in a system.
For example, when a user signs up, a webhook can send that data to another
system. Webhooks are efficient because they only send data when an event
happens, reducing the need for constant checking. However, they require the
receiving system to be available at the time of the event.
Pre-defined and
Rule Definition Based on real-time context or input
fixed
Example Use-
System logs filtering Personalized content recommendation
case