LogGrid is a fast, distributed log analysis and search system inspired by MapReduce and Splunk architectures. It is designed for parallel processing of gigabytes of text files distributed across multiple stateless compute nodes.
By leveraging modern C++ concurrency and a fully containerized ecosystem, LogGrid provides a blazing-fast, fault-tolerant infrastructure capable of ingesting and querying live log streams.
The system is built on an event-driven, push-based asynchronous TCP/IP architecture, orchestrated entirely via Docker Compose. It implements a Producer-Consumer pattern for log ingestion and consists of the following core components:
- Master (Server): The central coordinator. It manages the task queue, dispatches multiple tasks simultaneously to each Worker based on its thread count, and aggregates search results. It features robust Built-in Fault Tolerance – if a Worker crashes, all its in-flight tasks are immediately reclaimed and redistributed across all available idle Workers.
- Worker (Client): A highly optimized, stateless compute node. On connect it advertises its thread capacity via a
Worker_Hellohandshake. The Master immediately saturates all Worker threads with parallel tasks. Each completed task is acknowledged bytask_id, allowing multiple tasks to be in-flight simultaneously without ambiguity. - Log Generator / Shared Volume: A dynamic ingestion layer where microservices write live logs to a shared Docker Volume, allowing Workers to process incoming data on the fly. A Docker healthcheck ensures the Master starts only after the log file is fully generated.
- Infrastructure as Code (IaC): Fully containerized using
Dockerfile(Multi-stage builds) anddocker-compose.yml. Starts the entire distributed cluster with a single command. - Environment Agnostic: Eliminates OS-level dependencies (Windows/Linux conflicts) through isolated Ubuntu-based containers and environment variable configuration.
- Pipeline Dispatch: Master saturates all Worker threads immediately — dispatches N tasks per Worker on connect and replenishes after each
Worker_TaskDoneACK, eliminating idle gaps between task completions. - Zero-Downtime Reassignment: When a Worker crashes, all its in-flight tasks are reclaimed at once and redistributed across every available idle Worker in a single pass.
- High-Performance I/O: Asynchronous network streaming ensures the Master node is never blocked, even with dozens of connected Workers.
- Language: C++20 / C++23
- Networking: Asynchronous I/O based on Standalone ASIO (
asio::io_context). - Concurrency: Modern C++ threading primitives (
std::mutex,std::condition_variable, custom Thread Pool). - Infrastructure: Docker, Docker Compose, Linux (Ubuntu base images).
- Build System: CMake + Ninja.
Starting the entire distributed architecture takes only seconds:
- Clone the repository.
- Ensure you have Docker and Docker Compose installed.
- Spin up the Master and multiple Worker nodes using:
docker compose up -d --build
- To view the live, aggregated output of the cluster:
docker compose logs -f
Work in Progress — core networking, pipeline dispatch, fault tolerance, result aggregation and testing infrastructure are functional.
- Async TCP networking layer (Asio
io_context, non-blocking I/O) - Master-Worker task distribution protocol
- Fault Tolerance — full reclaim of all in-flight tasks on Worker disconnect, redistributed across all idle Workers
- Byte-aligned chunk splitting (correct line boundary detection)
- Result aggregation —
promise/futureper search session, results delivered to caller - Worker ThreadPool — parallel chunk processing via
std::thread::hardware_concurrency() - Docker healthcheck — Master waits for log file to be fully generated before starting
- Pipeline dispatch — Master dispatches N tasks per Worker simultaneously based on advertised thread count (
Worker_Hellohandshake); free slots tracked dynamically viam_workersFreeSlots - Per-task ACK —
Worker_TaskDonecarriestask_idfor precise completion tracking with multiple in-flight tasks per Worker - Worker ThreadPool optimization — use
hardware_concurrency() - 1threads to avoid starving the ASIO I/O thread - Unit tests — GoogleTest suite for
ThreadPool,FileProcessor,WorkerClientwith parametrized and edge-case coverage - Code coverage — gcov/lcov pipeline in CI, HTML report uploaded as artifact,
FileProcessorat 100% line coverage - Integration tests — real TCP end-to-end tests:
Worker_Hellohandshake, task dispatch withtask_idACK verification,Worker_FoundLinecontent matching
- HTTP API — Master exposes
/searchendpoint, replacing hardcodedStartSearchcall - Cloud deployment on AWS (EC2 instances as Worker nodes)
.
├── CMakeLists.txt
├── docker-compose.yml
├── Dockerfile
├── NetClient
│ ├── CMakeLists.txt
│ └── src
│ ├── FileProcessor.hpp
│ ├── main.cpp
│ ├── ThreadPool.hpp
│ ├── WorkerClient.cpp
│ └── WorkerClient.hpp
├── NetCommon
│ ├── CMakeLists.txt
│ └── include
│ ├── LogSearchCommon.hpp
│ ├── net_client.hpp
│ ├── net_common.hpp
│ ├── net_connection.hpp
│ ├── net_message.hpp
│ ├── net_server.hpp
│ ├── net_tsqueue.hpp
│ └── olc_net.hpp
├── NetServer
│ ├── CMakeLists.txt
│ └── src
│ ├── main.cpp
│ ├── MasterServer.cpp
│ └── MasterServer.hpp
├── tests
│ ├── CMakeLists.txt
│ ├── TestServer.hpp
│ ├── test_file_processor.cpp
│ ├── test_thread_pool.cpp
│ ├── test_worker_client.cpp
│ └── test_worker_integration.cpp
└── README.mdThe foundational networking layer (socket management, asynchronous thread-safe queues) is based on the olc::net architecture by javidx9 (OneLoneCoder). LogGrid extends this core with a custom application protocol, robust fault tolerance, and multi-threaded data processing.
