An open API service indexing awesome lists of open source software.

https://github.com/vfolgosa/bifrost-proxy

A lightweight Layer-7 Kafka proxy. Route traffic across clusters with port-based routing, SASL passthrough, and autonomous failover.
https://github.com/vfolgosa/bifrost-proxy

devops failover golang kafka kafka-proxy load-balancing proxy sre

Last synced: 3 days ago
JSON representation

A lightweight Layer-7 Kafka proxy. Route traffic across clusters with port-based routing, SASL passthrough, and autonomous failover.

Awesome Lists containing this project

README

          


Bifrost

# Bifrost โ€” Kafka L7 Proxy

> *"Route Kafka traffic across the nine realms."*

**Bifrost** is a lightweight, stateless **Layer-7 Apache Kafka proxy** written in Go. Routes Kafka protocol traffic using **port-based routing** โ€” each BU gets its own port, zero client-side changes beyond `bootstrap.servers`.

## โœจ Features

| | |
|---|---|
| ๐Ÿ”Œ **Port-Based Routing** | One port per BU. No TLS/SNI required. |
| ๐Ÿ” **SASL Passthrough** | Forwards SCRAM-SHA-512 and PLAIN credentials transparently. |
| ๐Ÿ“ **Metadata Rewrite** | Intercepts Metadata responses, rewrites broker addresses. |
| ๐ŸŽ›๏ธ **Three Modes** | `active_passive` ยท `load_balance` ยท `single` |
| โค๏ธ **Health Checks** | SASL-authenticated Metadata pings with configurable thresholds. |
| ๐Ÿ“ˆ **Live Dashboard** | Per-cluster health, records, bytes, failover events. |
| ๐Ÿ”ฅ **Hot Reload** | Edit `config.yaml` โ€” picks up changes without restart. |
| ๐Ÿ“ก **Prometheus** | `proxy_health_status` ยท `proxy_failover_total` ยท `proxy_connections_active` |

## ๐Ÿ—๏ธ Architecture


Bifrost Architecture

## ๐ŸŽ›๏ธ Cluster Modes


Cluster Modes

## ๐Ÿš€ Quick Start

```bash
# Start everything (Kafka + Bifrost + Redpanda + Prometheus)
docker compose up -d

# Produce
echo "hello bifrost" | kcat -P -b localhost:9094 \
-X security.protocol=SASL_PLAINTEXT \
-X sasl.mechanisms=PLAIN \
-X sasl.username=admin -X sasl.password=admin-secret \
-t logistics-topic

# Consume
kcat -C -b localhost:9094 \
-X security.protocol=SASL_PLAINTEXT \
-X sasl.mechanisms=PLAIN \
-X sasl.username=admin -X sasl.password=admin-secret \
-t logistics-topic -o beginning -e

# Dashboard
open http://localhost:8080
```

## ๐Ÿ“Š Monitoring

| Service | URL |
|---------|-----|
| Bifrost Dashboard | http://localhost:8080 |
| Prometheus | http://localhost:9090 |
| Redpanda kafka1 | http://localhost:8081 |
| Redpanda kafka2 | http://localhost:8082 |

## โš™๏ธ Configuration

```yaml
proxy:
bind_address: "0.0.0.0"
metrics_port: 8080

clusters:
# active_passive โ€” DR failover
finance:
port: 9093
mode: "active_passive"
active: "primary"
primary: "pkc-11111.us-east-1.aws.confluent.cloud:9092"
secondary: "pkc-22222.us-east-2.aws.confluent.cloud:9092"
health_check:
enabled: true
auto_failover: true
auto_failback: false

# load_balance โ€” weighted distribution
logistics:
port: 9094
mode: "load_balance"
primary:
bootstrap: "pkc-33333.us-east-1.aws.confluent.cloud:9092"
weight: 70
secondary:
bootstrap: "pkc-44444.us-east-2.aws.confluent.cloud:9092"
weight: 30
health_check:
enabled: true
auto_rebalance: true

# single โ€” standalone cluster
# legacy:
# port: 9095
# mode: "single"
# primary: "old-kafka.internal:9092"
```

## ๐Ÿ“š Documentation

| Doc | Description |
|-----|-------------|
| [Consumer Behavior](docs/consumer-behavior.md) | How consumers work with load balancing, failover, ordering, and deduplication |
| [Failover & Message Durability](docs/failover.md) | Adaptive health checks, detection windows, message loss risk, client config |
| [Broker Rollout](docs/broker-rollout.md) | Proxy behavior during Kafka rolling restarts and leader changes |
| [Roadmap](docs/roadmap.md) | Planned features and next steps |

## ๐Ÿ“ Project Structure

```
bifrost-proxy/
โ”œโ”€โ”€ cmd/proxy/ # Entry point
โ”œโ”€โ”€ internal/
โ”‚ โ”œโ”€โ”€ config/ # YAML parsing, validation, hot reload
โ”‚ โ”œโ”€โ”€ protocol/ # Kafka wire protocol parser
โ”‚ โ”œโ”€โ”€ proxy/ # TCP listener, connection handler, routing
โ”‚ โ”œโ”€โ”€ routing/ # SASL, metadata, produce/fetch routing
โ”‚ โ”œโ”€โ”€ pool/ # Connection pool, leader cache
โ”‚ โ”œโ”€โ”€ health/ # Health check engine
โ”‚ โ”œโ”€โ”€ failover/ # State machine, controller, rebalance
โ”‚ โ”œโ”€โ”€ logger/ # Structured JSON logging
โ”‚ โ””โ”€โ”€ server/ # HTTP server + embedded dashboard
โ”œโ”€โ”€ test/ # Test scripts
โ”œโ”€โ”€ assets/ # Diagrams and branding
โ”œโ”€โ”€ docker-compose.yml # Full dev stack
โ”œโ”€โ”€ Dockerfile # Multi-stage build
โ””โ”€โ”€ config.example.yaml # Example config
```

## ๐Ÿ“„ License

MIT