Lecture-1.1 PDC
### Synchronous Communication
1. **Definition**: In synchronous communication, components work in a coordinated way with a set order and timing. Here, the sender waits until the receiver confirms receipt before continuing.
2. **Characteristics**:
- **Real-Time Interaction**: The sender waits for the receiver’s reply before moving forward.
- **Request-Response Pattern**: A request is sent, and the sender pauses until a response comes back.
3. **Advantages and Disadvantages**:
- **Simplified Design**: It’s easy to design since processes are in sync, knowing exactly what’s happening when.
- **Potential Delays**: If the receiver takes time to respond, the sender is idle, which can slow down the system.
4. **Example**:
Imagine a **chat system** where every message you send has to be acknowledged by the other person immediately before you can send the next message. If the other person delays, you’re left waiting.
---
### Asynchronous Communication
1. **Definition**: In asynchronous communication, processes don’t wait for each other. The sender doesn’t need a reply right away and continues without delay.
2. **Characteristics**:
- **Independent Operations**: Processes can continue their tasks without stopping for responses.
- **Event-Driven**: Actions happen in response to events, and responses come whenever they’re ready, without set timing.
3. **Advantages and Disadvantages**:
- **Responsiveness and Scalability**: Faster as each component can operate freely. It’s also better suited for distributed systems as processes don’t depend on immediate replies.
- **Complexity**: Handling responses out of order and ensuring data is consistent can be challenging.
4. **Example**:
In an **email system**, you send an email without expecting an immediate response. The other person replies when they’re available, and you continue your work without waiting.
---
### Comparison in Distributed Systems
In distributed systems, choosing between synchronous and asynchronous approaches depends on your needs:
- **Performance**: Synchronous communication might slow things down due to wait times, while asynchronous can speed up tasks by allowing parallel processes.
- **Fault Tolerance**: Asynchronous communication improves fault tolerance since components aren’t directly dependent on each other’s responses.
- **Complexity**: Synchronous is simpler in structure, while asynchronous needs extra care with data management due to possible delays or reordering of messages.
- **Scalability**: Asynchronous setups are often more scalable, enabling multiple processes to run concurrently, utilizing resources effectively.
---
### Example Scenarios of Data Replication
#### Synchronous Replication
When you **write data to a master server**, it saves it and sends it to all replicas. The master only acknowledges your write request once all replicas confirm receiving the data. If even one replica fails, the whole system can’t proceed, ensuring **strong data consistency** but causing possible delays.
- **Downside**: The slowest replica or network link dictates the speed of the whole operation.
- **Failure Case**: If a replica becomes unavailable, the master stops taking writes, only allowing reads.
#### Asynchronous Replication
Here, the client gets confirmation as soon as the master records the data; replicas receive it later. This method provides **quick responses**, but if the master fails before updates reach all replicas, some data could be lost.
- **Downside**: Some data might be lost if there’s a failure, as replicas are not updated instantly.
#### Semi-Synchronous Replication
This is a **hybrid** approach: the master server waits for at least one replica to confirm the data before acknowledging the write. This balances consistency with better speed than full synchronous replication.
- **In a Single Replica Setup**: It acts like synchronous replication.
---
### Key Takeaways
1. **Synchronous Communication**: Waits for responses, ensuring coordination but may slow down processes.
2. **Asynchronous Communication**: No need for waiting; faster and more scalable, but handling consistency requires extra effort.
3. **Replication Methods**:
- Synchronous: Ensures full data consistency but might delay operations.
- Asynchronous: Quick but with less consistency.
- Semi-Synchronous: Balances speed and reliability.
This gives you a full view of synchronous and asynchronous concepts for your exam. Feel free to ask for more clarification on any part!
Comments
Post a Comment