Sign inSign up

tradik/mddb

By tradik

โ€ขUpdated 9 days ago

High-performance markdown database with gRPC/HTTP/3 - 29,810 docs/sec, 5.75x faster than MongoDB

Image
0

10K+

tradik/mddb repository overview

โ MDDB - High-Performance Markdown Database

Performance Go Version License

The fastest markdown database with gRPC and HTTP/3 support

MDDB is a specialized, high-performance database server designed for storing and managing markdown documents with rich metadata, full revision history, and dual protocol support (HTTP/JSON + gRPC/Protobuf).

โ ๐Ÿš€ Performance

  • 29,810 docs/sec throughput (37.4x baseline)
  • 34ยตs average latency
  • 5.75x faster than MongoDB
  • 6.89x faster than PostgreSQL
  • 24.54x faster than MySQL
  • 95.43x faster than CouchDB

โ โšก Key Features

  • Dual Protocol Support: HTTP/JSON REST API + gRPC/Protobuf
  • HTTP/3 Support: QUIC protocol for extreme performance
  • Full Revision History: Track all document changes with MVCC
  • Rich Metadata: Store and query structured metadata
  • Batch Operations: High-throughput batch insert/update/delete
  • Compression: Snappy and Zstd compression support
  • Lock-Free Cache: Sharded cache with zero contention
  • Adaptive Indexing: Smart metadata indexing
  • Built-in Backup: Hot backup and restore functionality
  • Embedded Database: BoltDB for zero-dependency deployment

โ ๐Ÿณ Quick Start

โ Production Server
docker run -d \
  --name mddb \
  -p 11023:11023 \
  -p 11024:11024 \
  -v mddb-data:/data \
  -e MDDB_PATH=/data/mddb.db \
  -e MDDB_MODE=wr \
  -e MDDB_EXTREME=true \
  tradik/mddb:latest
โ Docker Compose
version: '3.8'

services:
  mddb:
    image: tradik/mddb:latest
    container_name: mddb-server
    ports:
      - "11023:11023"  # HTTP
      - "11024:11024"  # gRPC
      - "11443:11443"  # HTTP/3 (extreme mode)
    volumes:
      - mddb-data:/data
    environment:
      - MDDB_PATH=/data/mddb.db
      - MDDB_MODE=wr
      - MDDB_EXTREME=true
      - MDDB_HTTP_PORT=11023
      - MDDB_GRPC_PORT=11024
      - MDDB_HTTP3_PORT=11443
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:11023/stats"]
      interval: 30s
      timeout: 10s
      retries: 3

volumes:
  mddb-data:

โ ๐Ÿ”ง Configuration

โ Environment Variables
VariableDefaultDescription
MDDB_PATH/data/mddb.dbDatabase file path
MDDB_MODEwrMode: ro (read-only) or wr (read-write)
MDDB_EXTREMEfalseEnable extreme performance mode
MDDB_HTTP_PORT11023HTTP server port
MDDB_GRPC_PORT11024gRPC server port
MDDB_HTTP3_PORT11443HTTP/3 server port (extreme mode)
โ Extreme Performance Mode

Enable with MDDB_EXTREME=true to activate:

  • HTTP/3 server with QUIC protocol
  • All 29 performance optimizations
  • Lock-free cache with sharding
  • Adaptive indexing
  • Compression (Snappy + Zstd)
  • Optimized batch processing
  • String allocation elimination
  • Zero-copy operations

โ ๐Ÿ“Š Available Tags

โ Production Images
  • latest - Latest stable release
  • 2.0.1, 2.0, 2 - Specific version tags
โ Platform Support

All images support:

  • linux/amd64 (Intel/AMD x86_64)
  • linux/arm64 (ARM/Apple Silicon aarch64)

โ ๐Ÿ”Œ API Examples

โ HTTP REST API
# Add a document
curl -X POST http://localhost:11023/add \
  -H "Content-Type: application/json" \
  -d '{
    "collection": "docs",
    "key": "welcome",
    "lang": "en",
    "meta": {
      "title": {"values": ["Welcome"]},
      "author": {"values": ["MDDB Team"]}
    },
    "content_md": "# Welcome to MDDB\n\nHigh-performance markdown database."
  }'

# Get a document
curl http://localhost:11023/get/docs/welcome/en

# Search documents
curl -X POST http://localhost:11023/search \
  -H "Content-Type: application/json" \
  -d '{
    "collection": "docs",
    "filter_meta": {
      "author": {"values": ["MDDB Team"]}
    },
    "limit": 10
  }'

# Batch insert (high performance)
curl -X POST http://localhost:11023/batch \
  -H "Content-Type: application/json" \
  -d '{
    "collection": "docs",
    "documents": [
      {
        "key": "doc1",
        "lang": "en",
        "meta": {"title": {"values": ["Document 1"]}},
        "content_md": "# Document 1"
      },
      {
        "key": "doc2",
        "lang": "en",
        "meta": {"title": {"values": ["Document 2"]}},
        "content_md": "# Document 2"
      }
    ]
  }'

# Get statistics
curl http://localhost:11023/stats
โ gRPC API
import (
    "google.golang.org/grpc"
    "mddb/proto"
)

conn, _ := grpc.Dial("localhost:11024", grpc.WithInsecure())
client := proto.NewMDDBClient(conn)

// Add document
doc, _ := client.Add(ctx, &proto.AddRequest{
    Collection: "docs",
    Key:        "welcome",
    Lang:       "en",
    Meta: map[string]*proto.MetaValues{
        "title": {Values: []string{"Welcome"}},
    },
    ContentMd: "# Welcome to MDDB",
})

// Batch insert (high performance)
resp, _ := client.AddBatch(ctx, &proto.AddBatchRequest{
    Collection: "docs",
    Documents: []*proto.BatchDocument{
        {
            Key:  "doc1",
            Lang: "en",
            Meta: map[string]*proto.MetaValues{
                "title": {Values: []string{"Document 1"}},
            },
            ContentMd: "# Document 1",
        },
        // ... more documents
    },
})

โ ๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                 Performance Layer                    โ”‚
โ”‚  โ€ข HTTP/3 Server (QUIC)                             โ”‚
โ”‚  โ€ข Lock-Free Cache (Sharded)                        โ”‚
โ”‚  โ€ข Batch Processor (Parallel + Single TX)           โ”‚
โ”‚  โ€ข String Optimization (Zero-Copy)                  โ”‚
โ”‚  โ€ข Compression (Snappy + Zstd)                      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                         โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                  Protocol Layer                      โ”‚
โ”‚  โ€ข HTTP/JSON REST API                               โ”‚
โ”‚  โ€ข gRPC/Protobuf API                                โ”‚
โ”‚  โ€ข HTTP/3 (Extreme Mode)                            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                         โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                   Storage Layer                      โ”‚
โ”‚  โ€ข BoltDB (Embedded)                                โ”‚
โ”‚  โ€ข MVCC (Multi-Version Concurrency Control)         โ”‚
โ”‚  โ€ข Adaptive Indexing                                โ”‚
โ”‚  โ€ข Revision History                                 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โ ๐Ÿ“ˆ Benchmarks

Tested with 3,000 documents on identical hardware:

DatabaseThroughputAvg Latencyvs MDDB
MDDB (Batch)25,863 docs/s39ยตs1.00x
MongoDB5,452 docs/s182ยตs4.74x slower
PostgreSQL3,360 docs/s297ยตs7.69x slower
MySQL1,183 docs/s845ยตs21.86x slower
CouchDB310 docs/s3,201ยตs83.39x slower

โ ๐Ÿ” Security

  • No authentication by default (add reverse proxy for production)
  • Runs as non-root user in container
  • Read-only mode available (MDDB_MODE=ro)
  • Volume permissions: 750 (owner: mddbd)

โ ๐Ÿ“ฆ Volume Management

# Create named volume
docker volume create mddb-data

# Backup database
docker run --rm \
  -v mddb-data:/data \
  -v $(pwd)/backups:/backups \
  tradik/mddb:latest \
  cp /data/mddb.db /backups/mddb-backup-$(date +%Y%m%d).db

# Restore database
docker run --rm \
  -v mddb-data:/data \
  -v $(pwd)/backups:/backups \
  tradik/mddb:latest \
  cp /backups/mddb-backup-20250107.db /data/mddb.db

โ ๐Ÿ› ๏ธ Troubleshooting

โ Check logs
docker logs mddb
โ Check health
curl http://localhost:11023/stats
โ Performance issues
  • Enable extreme mode: MDDB_EXTREME=true
  • Use batch operations for bulk inserts
  • Use gRPC for better performance than HTTP
  • Increase Docker resources (CPU/Memory)
โ Database locked
  • Ensure only one instance is running
  • Check file permissions on volume
  • Use read-only mode for multiple readers

โ ๐Ÿ“š Documentation

โ ๐Ÿค Support

โ ๐Ÿ“„ License

MIT License - see LICENSEโ 

โ ๐ŸŒŸ Why MDDB?

  • Performance First: 29 optimizations for maximum throughput
  • Developer Friendly: Simple API, easy deployment
  • Production Ready: Battle-tested, stable, reliable
  • Zero Dependencies: Embedded database, no external services
  • Modern Protocols: HTTP/3, gRPC, Protobuf
  • Rich Features: Metadata, revisions, search, backup
  • Open Source: MIT licensed, community driven

Made with โค๏ธ by the MDDB Team

Star us on GitHubโ  if you find MDDB useful!

Tag summary

Content type

Image

Digest

sha256:8fdc3fbe2โ€ฆ

Size

35.5 MB

Last updated

9 days ago

docker pull tradik/mddb