zapfs

command module
v0.0.0-...-79da9bc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 12, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

README

ZapFS

Go Version Build Status Coverage Go Report Card License

A distributed object storage system with an S3-compatible API, written in Go.

Architecture

flowchart TB
    subgraph Clients["S3 Clients"]
        C1["AWS SDK"]
        C2["s3cmd"]
        C3["mc"]
    end

    subgraph MetadataLayer["Metadata Service (:8082 HTTP, :8083 gRPC)"]
        direction TB
        API["S3 API Gateway<br/>• AWS Signature (SigV4/V2/Presigned/POST)<br/>• Bucket & object operations<br/>• Multipart, versioning, ACLs"]

        subgraph InternalClients["Internal Clients"]
            MC["Manager Client<br/>• IAM sync<br/>• Bucket registration<br/>• Placement"]
            FC["File Client<br/>• Chunk read/write<br/>• Streaming uploads<br/>• Replication"]
        end

        API --> MC & FC
    end

    subgraph ControlPlane["Manager Cluster (:8050 gRPC, :8051 Raft)"]
        MG1["Manager 1<br/>(Leader)"]
        MG2["Manager 2"]
        MG3["Manager 3"]

        MG1 <-->|Raft| MG2 & MG3
    end

    subgraph DataPlane["File Servers (:8081 gRPC)"]
        F1["File Server 1"]
        F2["File Server 2"]
        F3["File Server N"]
    end

    subgraph Storage["Storage Layer"]
        FS["Local/S3 Storage<br/>• Content-hash dedup<br/>• Erasure coding (RS)<br/>• RefCount GC<br/>• Replication (2+ copies)"]
    end

    subgraph Database["MySQL / Vitess"]
        DB1[("buckets, objects<br/>multipart_uploads<br/>ACLs, policies")]
        DB2[("usage_events<br/>usage_daily")]
        DB3[("tasks<br/>(task queue)")]
    end

    Clients -->|HTTP| API
    MC -->|gRPC| ControlPlane
    FC -->|gRPC| DataPlane
    DataPlane -->|gRPC| ControlPlane
    F1 & F2 & F3 --> FS
    MetadataLayer -->|SQL| Database
Components
Component Description
Manager Raft-based control plane for cluster coordination, IAM, and placement
Metadata S3-compatible API gateway with authentication and request routing
File Chunk storage servers with content-hash deduplication, erasure coding, and RefCount-based GC

Quick Start

Docker Compose (Development)
cd docker
docker compose up -d

# Test with AWS CLI
aws --endpoint-url=http://localhost:8082 s3 mb s3://test-bucket
aws --endpoint-url=http://localhost:8082 s3 cp README.md s3://test-bucket/
aws --endpoint-url=http://localhost:8082 s3 ls s3://test-bucket/
Kubernetes (Helm)
cd k8s/zapfs
helm dependency update
helm install zapfs . -n zapfs --create-namespace

Configuration

IAM Credentials

Default development credentials (change in production):

Access Key Secret Key
AKIAIOSFODNN7EXAMPLE wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

Configure via cmd/config/iam.toml or the Manager Admin API:

# Create a new user
curl -X POST http://localhost:8060/v1/iam/users \
  -H "Content-Type: application/json" \
  -d '{"username": "myuser"}'

# Create access key
curl -X POST http://localhost:8060/v1/iam/users/myuser/access-keys
Environment Variables
Variable Description Default
ZAPFS_IAM_MASTER_KEY Base64-encoded 32-byte key for encrypting secrets at rest (dev key)
LOG_LEVEL Logging level (debug, info, warn, error) info

Development

Building
# Build binary
go build -o zapfs .

# Run tests
go test ./...

# Generate mocks
make mocks
Running Locally
# Start manager (bootstrap node)
./zapfs manager --bootstrap --node_id=manager-1 --raft_dir=/tmp/raft

# Start metadata service
./zapfs metadata --manager_addr=localhost:8050 --db_driver=sqlite

# Start file server
./zapfs file --node_id=file-1

Performance

ZapFS is designed for high-throughput object storage. Benchmarks use MinIO WARP.

Quick Benchmark
# Start benchmark environment
docker compose -f docker/docker-compose.benchmark.yml up -d

# Run quick benchmark (1 min)
./scripts/benchmark.sh --profile quick

# Run standard benchmark (5 min) with output
./scripts/benchmark.sh --profile standard --output ./results
Benchmark Profiles
Profile Duration Best For
quick 1 min Sanity checks
standard 5 min General performance
large 5 min Large object workloads
small 5 min High-IOPS small files
mixed 10 min Realistic workloads

See docs/benchmarks/ for detailed methodology, environment setup, and recorded results.

Acknowledgments

ZapFS draws inspiration from several excellent open-source projects:

Project Inspiration License
SeaweedFS S3 API handlers, signature verification Apache 2.0
MinIO S3 error codes, IAM policy evaluation, erasure coding concepts AGPL 3.0
Ceph Distributed storage architecture, placement algorithms LGPL 2.1
HashiCorp Raft Consensus implementation for manager cluster MPL 2.0
Vitess MySQL-compatible distributed database (used for metadata) Apache 2.0

Some code patterns and S3 compatibility implementations were adapted from SeaweedFS under Apache 2.0 license.

License

ZapFS is open-core software with dual licensing:

Component License Description
Core (pkg/, cmd/, etc.) Apache 2.0 Open source, free forever
Enterprise (enterprise/, *_enterprise.go) Commercial Requires license key
Community Edition (Default)

The default build includes all core S3 functionality:

Category Features
Bucket Operations Create, Delete, List, Head, Location
Object Operations Put, Get, Delete, Copy, Head, List (v1/v2)
Multipart Upload Create, Upload Part, Complete, Abort, List Parts
Versioning Enable/Suspend, List Versions, Delete Markers
Access Control Bucket/Object ACLs, Bucket Policies
Configuration CORS, Website Hosting, Tagging, Encryption
Authentication AWS SigV4, SigV2, Presigned URLs, POST Policy
go build -o zapfs .
Enterprise Edition

Enterprise features require the enterprise build tag and a valid license key.

Get your license at zapfs.io — Start with a 14-day free trial.

go build -tags enterprise -o zapfs-enterprise .

To activate your license, place the license key file at /etc/zapfs/license.key or set the ZAPFS_LICENSE_KEY environment variable:

# Option 1: File-based
sudo mkdir -p /etc/zapfs
sudo cp ~/Downloads/zapfs-license.key /etc/zapfs/license.key

# Option 2: Environment variable
export ZAPFS_LICENSE_KEY=$(cat ~/Downloads/zapfs-license.key)
Enterprise Features
Feature License Required Description
Usage Reporting FeatureAdvancedMetrics Storage, bandwidth, and request tracking
Lifecycle Rules FeatureLifecycle Object expiration and transitions
Object Lock (WORM) FeatureObjectLock Retention and legal hold
SSE-KMS Encryption FeatureKMS KMS-managed encryption keys
Bucket Access Logging FeatureAccessLog S3 access logs to target bucket
Cross-Region Replication FeatureMultiRegion Replicate to remote regions
LDAP/AD Integration FeatureLDAP Directory service authentication
OIDC/SSO Integration FeatureOIDC OpenID Connect single sign-on
Event Notifications FeatureEvents S3 event notifications (SNS/SQS/Lambda)
Backup & DR FeatureBackup Raft state backup and restore

See LICENSE and LICENSE.enterprise for details.

Enterprise Support

For enterprise licensing, support, and custom deployments:

  • Portal: zapfs.io — Manage licenses and subscriptions
  • Documentation: zapfs.io/docs — Setup guides and API reference

Star History

Star History Chart

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package cmd provides CLI command implementations for ZapFS services.
Package cmd provides CLI command implementations for ZapFS services.
enterprise
events
Package events provides stubs for enterprise event notification handlers.
Package events provides stubs for enterprise event notification handlers.
license
Package license provides enterprise license types.
Package license provides enterprise license types.
taskqueue
Package taskqueue provides stubs for enterprise-only task handlers.
Package taskqueue provides stubs for enterprise-only task handlers.
mocks
db
ec
iam
pkg
compression
Package compression provides data compression and decompression utilities for ZapFS storage.
Package compression provides data compression and decompression utilities for ZapFS storage.
env
events
Package events provides S3 event notification infrastructure.
Package events provides S3 event notification infrastructure.
grpc/pool
Package pool provides generic gRPC connection pooling with optional cluster-aware routing for Raft-based services.
Package pool provides generic gRPC connection pooling with optional cluster-aware routing for Raft-based services.
iam
license
Package license provides a license checking interface for feature gating.
Package license provides a license checking interface for feature gating.
manager
Package manager provides stub region configuration for community edition.
Package manager provides stub region configuration for community edition.
metadata/client
Package client defines interfaces for external service clients used by the metadata server.
Package client defines interfaces for external service clients used by the metadata server.
metadata/db/memory
Package memory provides an in-memory implementation of db.DB for testing.
Package memory provides an in-memory implementation of db.DB for testing.
metadata/db/postgres
Package postgres provides a PostgreSQL/CockroachDB implementation of the db.DB interface.
Package postgres provides a PostgreSQL/CockroachDB implementation of the db.DB interface.
metadata/db/sql
Package sql provides a dialect-aware SQL database implementation.
Package sql provides a dialect-aware SQL database implementation.
metadata/db/vitess
Package vitess provides a Vitess/MySQL implementation of the db.DB interface.
Package vitess provides a Vitess/MySQL implementation of the db.DB interface.
metadata/service
Package service provides the business logic layer for the metadata server.
Package service provides the business logic layer for the metadata server.
metadata/service/encryption
Package encryption provides encryption/decryption services for SSE-C and SSE-KMS.
Package encryption provides encryption/decryption services for SSE-C and SSE-KMS.
metadata/service/gc
Package gc provides centralized garbage collection for the chunk registry.
Package gc provides centralized garbage collection for the chunk registry.
metadata/service/lifecycle
Package lifecycle provides lifecycle policy scanning and execution.
Package lifecycle provides lifecycle policy scanning and execution.
metadata/service/s3select
Package s3select provides S3 Select functionality for querying objects using SQL.
Package s3select provides S3 Select functionality for querying objects using SQL.
metadata/service/storage
Package storage provides coordination between file servers and the manager for object storage operations.
Package storage provides coordination between file servers and the manager for object storage operations.
s3client
Package s3client provides a connection pool for external S3 clients.
Package s3client provides a connection pool for external S3 clients.
storage/backend
Package backend provides storage backend implementations.
Package backend provides storage backend implementations.
taskqueue
Package taskqueue provides a durable task queue for background processing.
Package taskqueue provides a durable task queue for background processing.
taskqueue/handlers
Package handlers provides task handlers for the task queue.
Package handlers provides task handlers for the task queue.
usage
Package usage provides usage tracking and reporting for billing.
Package usage provides usage tracking and reporting for billing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL