A high-performance, distributed log ingestion and search system built in Go, designed to handle 50,000+ log events/sec with batched writes, Kafka-backed durability, and PostgreSQL indexing for fast querying.
- Language: Go
- Messaging: Apache Kafka (bitnami image for local dev)
- Database: PostgreSQL + trigram index for fast text search
- Containerization: Docker Compose
- Design: Event-driven, scalable, and fault-tolerant pipeline
- Services:
ingestion-service/,consumer-service/,search-service/ - Local-compose:
docker-compose.yml - Run script:
run.sh
- HTTP ingestion endpoint (
/ingest) with concurrency-safe batching (flush on 100 logs or 100ms) - Kafka-backed durability to decouple ingestion from persistence
- Consumer service that writes to PostgreSQL with batched/prepared inserts
- Search API supporting indexed full-text search with optional caching
- Simple deployment with Docker Compose for local testing
+----------------------+ +------------------+ +---------------------+
| Ingestion Service | ---> | Kafka (logs) | ---> | Consumer Service |
| (HTTP + batching) | | | | (Kafka -> Postgres) |
+----------------------+ +------------------+ +---------------------+
|
v
+----------------+
| PostgreSQL |
| (GIN trigram) |
+----------------+
^
|
+----------------+
| Search Service |
| (HTTP / cache) |
+----------------+
- Go 1.18+ (1.22 recommended)
- Docker & Docker Compose
- git
docker compose up -dConnect to Postgres and run:
CREATE TABLE IF NOT EXISTS logs (
id SERIAL PRIMARY KEY,
source TEXT,
message TEXT,
ts BIGINT,
created_at TIMESTAMP DEFAULT NOW()
);
CREATE EXTENSION IF NOT EXISTS pg_trgm;
CREATE INDEX IF NOT EXISTS idx_logs_message ON logs USING GIN (message gin_trgm_ops);In three terminals:
cd ingestion-service && go run main.go
cd consumer-service && go run main.go
cd search-service && go run main.goOr use the included run.sh to run everything locally (for demo purposes).
run.sh will:
- Bring up Docker Compose
- Run all three services in background using
nohup(for demo only) - Tail logs for quick inspection
Note:
run.shis intended for local demos. For production use, use proper process managers or Docker/Kubernetes.
- Batch size: 100 logs / flush interval: 100ms (tuneable via env vars)
- Use
abor custom Go producers to simulate load - Add pg_trgm index for fast substring search
.
├── README.md
├── docker-compose.yml
├── run.sh
├── ingestion-service/
├── consumer-service/
└── search-service/
See CONTRIBUTING.md for guidelines.
This project is licensed under the MIT License - see the LICENSE file for details.