How Qlib-Server works
mainQlib-Server is a centralized data management system for Qlib that enables 'online' mode. It uses a Client/Server framework based on WebSockets to allow bidirectional, asynchronous communication.
Key components of the workflow include:
- Request Handling: The server listens for client requests via WebSockets. It uses a
RequestListenerto parse requests and identifies identical requests from different clients to prevent redundant data generation. - Task Queuing: Parsed tasks are submitted to a
RabbitMQpipe in a channel namedtask_queue. - Concurrency Control: The server uses
Redisto track session IDs of clients requesting the same data and employsRedis_Lockto prevent IO conflicts during simultaneous read/write operations. - Data Processing: A
DataProcessorconsumes tasks from RabbitMQ. It usesqlib.data.Providerto perform calculations for three specific task types:Calendar,Instruments, andFeatures. - Result Delivery: Once processing is complete, results (either raw data or URIs) are published to a
message_queue. ARequestResponderthen consumes these results and sends them back to the corresponding clients.