A distributed, replicated log system built in Go. Proglog provides a high-performance, fault-tolerant log storage and retrieval system with strong consistency guarantees using the Raft consensus algorithm.
- Distributed Log Storage: Replicated log storage across multiple nodes for high availability
- Raft Consensus: Uses HashiCorp Raft for distributed consensus and leader election
- Service Discovery: Serf-based cluster membership and service discovery
- gRPC API: High-performance gRPC interface for produce/consume operations
- Streaming Support: Bidirectional streaming for real-time log consumption and production
- TLS Security: End-to-end encryption for both client-server and peer-to-peer communication
- Access Control: Casbin-based ACL (Access Control List) for fine-grained authorization
- Memory-Mapped I/O: Efficient log storage using memory-mapped files
- Kubernetes Ready: Helm charts for easy deployment on Kubernetes
- Load Balancing: Client-side load balancing with service discovery integration
Proglog is built with a modular architecture:
┌───────────────────────────────────────────────┐
│ Client Applications │
└────────────────────┬──────────────────────────┘
│
┌───────────┴───────────┐
│ │
┌────▼────┐ ┌─────▼─────┐
│ gRPC │ │ HTTP │
│ API │ │ Server │
└────┬────┘ └───────────┘
│
┌────▼─────────────────────────────────┐
│ Agent (Main Component) │
│ ┌──────────┐ ┌──────────────────┐ │
│ │ Log │ │ Membership │ │
│ │ (Raft) │ │ (Serf) │ │
│ └──────────┘ └──────────────────┘ │
└──────────────────────────────────────┘
- Agent: Main orchestrator that manages log, server, and membership
- Log: Distributed log implementation using Raft for consensus
- Server: gRPC and HTTP server implementations
- Discovery: Serf-based cluster membership management
- Load Balance: Client-side load balancing and service resolution
- Auth: Casbin-based authorization layer
- Go 1.25.5 or later
- Protocol Buffers compiler (
protoc) - Go plugins for protoc:
google.golang.org/protobuf/cmd/protoc-gen-gogoogle.golang.org/grpc/cmd/protoc-gen-go-grpc
- CFSSL (for certificate generation)
- Docker (optional, for containerized deployment)
- Kubernetes cluster (optional, for Kubernetes deployment)
- Clone the repository:
git clone https://github.com/tabrizgulmammadov/proglog.git
cd proglog- Install dependencies:
go mod download- Generate protobuf code:
make compile- Build the binary:
go build -o bin/proglog ./cmd/proglogBuild the Docker image:
make build-docker TAG=0.0.1Or use Docker directly:
docker build -t github.com/tabrizgulmammadov/proglog:0.0.1 .- Initialize the configuration directory:
make init- Generate TLS certificates:
make gencertThis creates:
- CA certificate and key
- Server certificate and key
- Client certificates (root-client and nobody-client)
- Copy ACL configuration files:
cp test/model.conf ${HOME}/.proglog/model.conf
cp test/policy.csv ${HOME}/.proglog/policy.csvThe proglog command supports the following flags:
| Flag | Description | Default |
|---|---|---|
--config-file |
Path to config file | - |
--data-dir |
Directory to store log and Raft data | /tmp/proglog |
--node-name |
Unique server ID | Hostname |
--bind-addr |
Address to bind Serf on | 127.0.0.1:8401 |
--rpc-port |
Port for RPC clients (and Raft) | 8400 |
--start-join-addrs |
Serf addresses to join | - |
--bootstrap |
Bootstrap the cluster | false |
--acl-model-file |
Path to ACL model | - |
--acl-policy-file |
Path to ACL policy | - |
--server-tls-cert-file |
Path to server TLS cert | - |
--server-tls-key-file |
Path to server TLS key | - |
--server-tls-ca-file |
Path to server CA | - |
--peer-tls-cert-file |
Path to peer TLS cert | - |
--peer-tls-key-file |
Path to peer TLS key | - |
--peer-tls-ca-file |
Path to peer CA | - |
./bin/proglog \
--data-dir /tmp/proglog/node1 \
--node-name node1 \
--bind-addr 127.0.0.1:8401 \
--rpc-port 8400 \
--bootstrapNode 1 (Bootstrap):
./bin/proglog \
--data-dir /tmp/proglog/node1 \
--node-name node1 \
--bind-addr 127.0.0.1:8401 \
--rpc-port 8400 \
--bootstrapNode 2:
./bin/proglog \
--data-dir /tmp/proglog/node2 \
--node-name node2 \
--bind-addr 127.0.0.1:8402 \
--rpc-port 8401 \
--start-join-addrs 127.0.0.1:8401Node 3:
./bin/proglog \
--data-dir /tmp/proglog/node3 \
--node-name node3 \
--bind-addr 127.0.0.1:8403 \
--rpc-port 8402 \
--start-join-addrs 127.0.0.1:8401,127.0.0.1:8402./bin/proglog \
--data-dir /tmp/proglog/node1 \
--node-name node1 \
--bind-addr 127.0.0.1:8401 \
--rpc-port 8400 \
--server-tls-cert-file ${HOME}/.proglog/server.pem \
--server-tls-key-file ${HOME}/.proglog/server-key.pem \
--server-tls-ca-file ${HOME}/.proglog/ca.pem \
--peer-tls-cert-file ${HOME}/.proglog/server.pem \
--peer-tls-key-file ${HOME}/.proglog/server-key.pem \
--peer-tls-ca-file ${HOME}/.proglog/ca.pem \
--bootstrapUse the getservers command to query cluster membership:
go run ./cmd/getservers --addr localhost:8400Proglog exposes a gRPC API defined in api/v1/log.proto:
- Produce: Append a record to the log
- Consume: Read a record at a specific offset
- ConsumeStream: Stream records starting from an offset
- ProduceStream: Bidirectional streaming for producing records
- GetServers: Get the list of servers in the cluster
import (
"context"
api "github.com/tabrizgulmammadov/proglog/api/v1"
"google.golang.org/grpc"
)
conn, _ := grpc.Dial("localhost:8400", grpc.WithInsecure())
client := api.NewLogClient(conn)
// Produce a record
produceResp, _ := client.Produce(context.Background(), &api.ProduceRequest{
Record: &api.Record{
Value: []byte("hello world"),
},
})
// Consume a record
consumeResp, _ := client.Consume(context.Background(), &api.ConsumeRequest{
Offset: produceResp.Offset,
})make testThis will:
- Copy ACL configuration files to
${HOME}/.proglog/ - Run all tests with race detection
proglog/
├── api/v1/ # Protocol buffer definitions and generated code
├── cmd/
│ ├── proglog/ # Main server command
│ ├── server/ # HTTP server example
│ └── getservers/ # Server discovery client
├── internal/
│ ├── agent/ # Main agent orchestrator
│ ├── auth/ # Authorization layer (Casbin)
│ ├── config/ # Configuration management
│ ├── discovery/ # Serf-based service discovery
│ ├── loadbalance/ # Client-side load balancing
│ ├── log/ # Distributed log implementation
│ └── server/ # gRPC and HTTP servers
├── deploy/ # Kubernetes deployment manifests
│ ├── proglog/ # Proglog Helm chart
│ └── metacontroller/ # Metacontroller Helm chart
└── test/ # Test certificates and ACL configs
Generate protobuf code:
make compileDeploy using Helm:
# Install the chart
helm install proglog ./deploy/proglog
# Or with custom values
helm install proglog ./deploy/proglog -f custom-values.yamlThe Helm chart includes:
- StatefulSet for ordered, stable deployment
- Service per pod for service discovery
- ConfigMaps and Secrets support
- Health checks and readiness probes
Example docker-compose.yml:
version: '3.8'
services:
node1:
image: github.com/tabrizgulmammadov/proglog:0.0.1
ports:
- "8401:8401"
- "8400:8400"
command: ["--bootstrap", "--data-dir", "/data"]
volumes:
- node1-data:/data
node2:
image: github.com/tabrizgulmammadov/proglog:0.0.1
ports:
- "8402:8401"
- "8401:8400"
command: ["--start-join-addrs", "node1:8401", "--data-dir", "/data"]
volumes:
- node2-data:/data
depends_on:
- node1
volumes:
node1-data:
node2-data:- TLS Encryption: All client-server and peer-to-peer communication can be encrypted with TLS
- ACL Authorization: Fine-grained access control using Casbin policies
- Certificate Management: CFSSL-based certificate generation and management
- Memory-Mapped I/O: Uses memory-mapped files for efficient log storage
- Segment-Based Storage: Logs are stored in segments for efficient rotation and compaction
- Raft Batching: Raft operations are batched for better throughput
- Connection Multiplexing: Uses cmux for multiplexing gRPC and Raft on the same port
- Port conflicts: Ensure ports 8400 (RPC) and 8401 (Serf) are available
- Certificate errors: Verify TLS certificates are correctly generated and paths are correct
- Cluster formation: Ensure at least one bootstrap node is started before other nodes join
- Data directory permissions: Ensure the data directory is writable
- Config file format errors: In Kubernetes, ensure
start-join-addrsis formatted as a YAML array:["addr1:port", "addr2:port"]not as a string
If pods are failing in Kubernetes:
- Check pod logs:
kubectl logs proglog-0- Check the generated config file:
kubectl exec proglog-0 -- cat /var/run/proglog/config.yaml- Verify the config file format - The
start-join-addrsshould be a YAML array:
start-join-addrs: ["proglog-0.proglog.default.svc.cluster.local:8401"]Not a string:
start-join-addrs: "proglog-0.proglog.default.svc.cluster.local:8401" # WRONG- Check if the data directory exists and is writable:
kubectl exec proglog-0 -- ls -la /var/run/proglog/- Describe the pod for events:
kubectl describe pod proglog-0- Check if the service is accessible:
kubectl get svc
kubectl get endpointsEnable debug logging by setting the log level in the agent configuration or using environment variables.
Contributions are welcome! Please feel free to submit a Pull Request.
See LICENSE file for details.