Backend State Synchronization for Non-Blocking RPC Services
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing RPC messaging systems in microservices with substantial response times can lead to blocking commands, causing delayed processing and inconsistent object states, leading to confusion and inefficiencies.
Innovation Solution
Implement a backend service with a management task that does not block on managed object response delays, using a single thread scheduler and background maintenance tasks to handle commands, ensuring consistent object states through cooperative multitasking or alternative concurrency technologies.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Speed
If the backend service processes commands synchronously with blocking waits for managed object responses, then command processing is simple and straightforward, but the RPC reply is delayed and the system responds slowly to client requests
Solution Approach 1:
The backend service is segmented into two independent task types: management tasks that handle RPC commands without blocking, and maintenance tasks that handle the actual blocking operations on managed objects. This segmentation allows the management task to return RPC replies immediately while maintenance tasks handle the slow operations in the background, resolving the contradiction between fast RPC replies and simple processing.
2Speed
If the backend service queues incoming commands for background processing to achieve non-blocking RPC, then RPC replies are immediate, but command processing is delayed and object state consistency becomes problematic
Solution Approach 1:
The system implements feedback through events that notify the management task when maintenance tasks complete their operations. When a maintenance task finishes processing a managed object, it generates an event that updates the object's state in the data structure, ensuring that subsequent RPC commands receive accurate, consistent state information. This feedback mechanism resolves the contradiction between immediate RPC replies and reliable state consistency.
Solution Approach 2:
A data structure acts as an intermediary between the management task and maintenance tasks, maintaining the authoritative state of all managed objects. The management task queries this data structure for current state information, while maintenance tasks update it upon completion, ensuring all components work with consistent state data without requiring the management task to wait for maintenance operations.
3Speed
If the backend service uses multithreading or multiprocessing to handle blocking operations, then RPC replies are non-blocking, but thread allocation costs and locking overhead increase
Solution Approach 1:
The system uses cooperative multitasking with async/await technology, allowing the management task to yield control during blocking operations and resume when complete, without requiring multiple threads or processes. This self-service approach eliminates thread allocation costs and locking overhead while maintaining non-blocking RPC behavior, as the single thread efficiently manages both management and maintenance tasks through cooperative scheduling.
4Reliability
If the backend service implements comprehensive command queuing and state management to ensure consistency, then object state consistency is maintained, but memory footprint increases
Solution Approach 1:
The system extracts only the essential state information of managed objects into a compact data structure, maintaining minimal memory footprint. Rather than storing complete object states or complex queuing structures, the data structure holds only the critical state data needed for consistency, with full object details remaining in the managed objects themselves. This extraction approach maintains reliability while minimizing memory usage.
Data Source
AI summary
A method, computer program product, and computer system for implementing a backend service for blocking free processing of physical entities events, including add, remove, update, query. Physical entities blocking delays may be delegated to maintenance tasks, which may run under a single thread with a scheduler and may merge successive pending events.


