gRPC Unary vs Streaming Interview Questions and Answers (15 Must-Know Questions)
Master gRPC communication patterns with 15 interview questions and answers. Learn Unary RPC, Server Streaming, Client Streaming, Bidirectional Streaming, HTTP/2 streams, Spring Boot implementation, production use cases, performance optimization, and enterprise best practices.
Introduction
One of the biggest advantages of gRPC over traditional REST APIs is its support for multiple communication patterns. While REST primarily follows a simple request-response model, gRPC supports Unary RPC, Server Streaming, Client Streaming, and Bidirectional Streaming.
These communication models allow developers to choose the most efficient interaction pattern based on business requirements. For example, a banking application may use Unary RPC for account balance retrieval, Server Streaming for transaction history, Client Streaming for bulk uploads, and Bidirectional Streaming for real-time trading or chat systems.
Because these patterns are frequently discussed in Java, Spring Boot, Cloud, and Solution Architect interviews, understanding when and why to use each one is essential.
What You'll Learn
- Unary RPC
- Server Streaming
- Client Streaming
- Bidirectional Streaming
- HTTP/2 Streams
- Spring Boot Integration
- Enterprise Use Cases
- Performance Considerations
- Best Practices
- Production Architecture
gRPC Communication Models
flowchart TD
GC["gRPC Communication"]
GC --> UN["Unary"]
GC --> SS["Server Streaming"]
GC --> CS["Client Streaming"]
GC --> BD["Bidirectional Streaming"]
RPC Communication Flow
flowchart TD
C["Client"] --> RT["Choose RPC Type"]
RT --> H2["HTTP/2 Stream"]
H2 --> GS["gRPC Server"]
GS --> BL["Business Logic"]
BL --> RS["Response(s)"]
1. What is Unary RPC?
Answer
Unary RPC is the simplest communication model in gRPC.
The client sends one request, and the server returns one response.
Example
Client
↓
Get User Request
↓
Server
↓
User Response
Example use cases:
- Login
- User lookup
- Balance inquiry
- Product details
- Customer profile
Unary RPC is the closest equivalent to a REST API request.
2. What is Server Streaming RPC?
Answer
In Server Streaming, the client sends one request, and the server returns multiple responses over the same connection.
Example
Client
↓
Transaction History Request
↓
Transaction 1
↓
Transaction 2
↓
Transaction 3
↓
Complete
Typical use cases:
- Transaction history
- Live logs
- Analytics
- Report generation
- IoT sensor updates
3. What is Client Streaming RPC?
Answer
In Client Streaming, the client sends multiple requests, and the server returns one response after processing all requests.
Example
Upload File Part 1
↓
Upload File Part 2
↓
Upload File Part 3
↓
Server
↓
Upload Completed
Common use cases:
- File uploads
- Bulk inserts
- Sensor data collection
- Batch processing
4. What is Bidirectional Streaming RPC?
Answer
Both client and server continuously exchange messages independently.
Example
Client ⇄ Server
Message 1
Message 2
Message 3
Real-Time Updates
Typical use cases:
- Chat systems
- Stock trading
- Multiplayer gaming
- Collaborative editing
- Live monitoring
5. How Does HTTP/2 Enable Streaming?
Answer
HTTP/2 supports multiple independent streams over a single TCP connection.
Features include:
- Multiplexing
- Full-duplex communication
- Header compression
- Persistent connections
- Flow control
These capabilities make streaming highly efficient.
6. How Does Spring Boot Implement Unary RPC?
Answer
Example
@Override
public void getUser(UserRequest request,
StreamObserver<UserResponse> responseObserver) {
UserResponse response = service.find(request.getId());
responseObserver.onNext(response);
responseObserver.onCompleted();
}
The server processes one request and sends one response.
7. How Does Spring Boot Implement Server Streaming?
Answer
Example
@Override
public void getTransactions(
TransactionRequest request,
StreamObserver<Transaction> observer) {
transactions.forEach(observer::onNext);
observer.onCompleted();
}
The server continuously sends multiple responses until processing completes.
8. How Does Spring Boot Implement Client Streaming?
Answer
Example
@Override
public StreamObserver<FileChunk> uploadFile(
StreamObserver<UploadResponse> responseObserver) {
return new StreamObserver<FileChunk>() {
@Override
public void onNext(FileChunk chunk) {
// Process chunk
}
@Override
public void onCompleted() {
responseObserver.onNext(response);
responseObserver.onCompleted();
}
};
}
The client streams multiple messages before receiving the final response.
9. How Does Spring Boot Implement Bidirectional Streaming?
Answer
Example
@Override
public StreamObserver<ChatMessage> chat(
StreamObserver<ChatMessage> responseObserver) {
return new StreamObserver<ChatMessage>() {
@Override
public void onNext(ChatMessage message) {
responseObserver.onNext(message);
}
};
}
Both client and server send messages independently without waiting for each other.
10. When Should Each RPC Type Be Used?
Answer
| RPC Type | Best Use Cases |
|---|---|
| Unary | CRUD operations, login, search |
| Server Streaming | Reports, notifications, logs |
| Client Streaming | Bulk uploads, batch processing |
| Bidirectional Streaming | Chat, trading, gaming, IoT |
Selecting the appropriate communication model improves scalability and efficiency.
11. What are Common Streaming Design Mistakes?
Answer
Common mistakes include:
- Using Unary for continuous updates
- Ignoring backpressure
- Large streaming messages
- Missing deadlines
- No cancellation handling
- Blocking server threads
- Weak authentication
- No flow control
- Missing monitoring
- Improper resource cleanup
12. What are Enterprise Streaming Best Practices?
Answer
Recommended practices:
- Choose the correct RPC type
- Keep messages small
- Enable TLS
- Configure deadlines
- Handle cancellations
- Validate streamed data
- Monitor stream health
- Implement retries carefully
- Log streaming metrics
- Close streams properly
13. How Should Streaming Services be Monitored?
Answer
Important production metrics include:
- Active streams
- Request latency
- Stream duration
- Throughput
- Error rate
- Cancellation count
- Connection count
- CPU utilization
- Memory usage
- Network bandwidth
These metrics help maintain reliable streaming services.
14. How Does Streaming Compare with REST?
Answer
| Feature | REST | gRPC Streaming |
|---|---|---|
| Request Model | Request-Response | Continuous Streams |
| HTTP Version | HTTP/1.1 | HTTP/2 |
| Real-Time Support | Polling/WebSockets | Native |
| Payload | JSON | Protobuf |
| Performance | Moderate | High |
Streaming eliminates repeated HTTP requests and significantly reduces latency for real-time applications.
15. What Does an Enterprise gRPC Streaming Architecture Look Like?
Answer
Mobile Apps • Web Apps • IoT Devices
│
▼
gRPC Gateway
│
HTTP/2 Streams
│
┌──────────────┼──────────────┐
▼ ▼ ▼
Unary Service Streaming Service Chat Service
│ │ │
▼ ▼ ▼
Database Kafka Topics Redis Pub/Sub
│ │ │
└──────────────┼──────────────┘
▼
Prometheus • Grafana • Jaeger
Enterprise Components
- gRPC Gateway
- Unary Services
- Streaming Services
- HTTP/2
- Protocol Buffers
- Kafka
- Redis Pub/Sub
- Database
- Monitoring
- Distributed Tracing
Unary vs Streaming Summary
| Communication Type | Request | Response | Typical Use Case |
|---|---|---|---|
| Unary | One | One | CRUD, Login |
| Server Streaming | One | Many | Reports, Notifications |
| Client Streaming | Many | One | Uploads, Batch Processing |
| Bidirectional Streaming | Many | Many | Chat, Trading, IoT |
Interview Tips
- Explain that gRPC supports four RPC communication models, unlike REST's request-response model.
- Describe Unary RPC as the equivalent of a traditional REST API call.
- Explain Server Streaming with examples such as transaction history, reports, and live log streaming.
- Discuss Client Streaming for file uploads, sensor data collection, and bulk processing.
- Explain Bidirectional Streaming using chat applications, stock trading, or multiplayer gaming.
- Highlight how HTTP/2 multiplexing enables efficient streaming over a single connection.
- Discuss Spring Boot implementations using
StreamObserver. - Mention production considerations such as deadlines, cancellations, flow control, and monitoring.
- Compare gRPC Streaming with REST polling and WebSocket-based solutions.
- Use enterprise examples involving banking, cloud infrastructure, IoT, and real-time analytics to demonstrate when each communication model should be selected.
Key Takeaways
- gRPC supports four communication models: Unary, Server Streaming, Client Streaming, and Bidirectional Streaming.
- Unary RPC is ideal for request-response operations such as CRUD APIs and authentication.
- Server Streaming enables efficient delivery of multiple responses for a single request.
- Client Streaming is well suited for bulk uploads, telemetry collection, and batch processing.
- Bidirectional Streaming supports full-duplex communication for real-time applications.
- HTTP/2 provides multiplexing, persistent connections, and flow control, making streaming highly efficient.
- Spring Boot implements streaming services using
StreamObserver. - Selecting the appropriate RPC model improves performance, scalability, and user experience.
- Production systems should monitor stream health, throughput, latency, and resource utilization.
- Unary vs Streaming is one of the most frequently asked gRPC interview topics for Java, Spring Boot, Microservices, Cloud, and Solution Architect roles.