Skip to content
/ zzz Public

A library for writing performant and reliable networked services.

License

Notifications You must be signed in to change notification settings

mookums/zzz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zzz

zzz logo

Installing

Tracking Latest Zig Stable: 0.13.0

zig fetch --save git+https://github.com/mookums/zzz#main

You can then add the dependency in your build.zig file:

const zzz = b.dependency("zzz", .{
    .target = target,
    .optimize = optimize,
}).module("zzz");

exe.root_module.addImport(zzz);

zzz?

zzz is a framework for writing performant and reliable networked services in Zig. It currently only supports TCP as the underlying transport layer but allows for any arbitrary protocol to run on top.

zzz is currently alpha software and while it is generally stable, there is still a lot changing at a fairly quick pace and certain places where things are less polished.

It focuses on modularity and portability, allowing you to swap in your own implementations for various things. Consumers can provide both a protocol and an async implementation, allowing for maximum flexibility. This allows for use in standard servers as well as embedded/bare metal domains.

For more information, look here:

  1. Getting Started
  2. HTTPS
  3. Performance Tuning
  4. Custom Async

Optimization

zzz is very fast. Through a combination of methods, such as allocation at start up and avoiding thread contention, we are able to extract tons of performance out of a fairly simple implementation. zzz is quite robust currently but is still early stage software. It's currently been running in production, serving my site.

We are nearly as fast as gnet (zzz is 2% slower at 1000 concurrent connections), the fastest plaintext HTTP server according to TechEmpower, while consuming only ~21% of the memory that gnet requires.

benchmark (request per sec)

Raw Data

benchmark (peak memory)

Raw Data

On the CCX63 instance on Hetzner, we are 66.4% faster than zap and 77% faster than http.zig. We also utilize less memory, using only ~3% of the memory used by zap and ~18% of the memory used by http.zig.

zzz can be configured to utilize minimal memory while remaining performant. The provided minram example only uses 392 kB!

Features

  • Modular Asynchronous Implementation
    • Allows for passing in your own Async implementation.
    • Comes with:
      • io_uring for Linux.
      • IOCP for Windows (planned).
      • kqueue for BSD (planned).
  • Modular Protocol Implementation #
    • Allows for defining your own Protocol on top of TCP.
  • Single and Multi-threaded Support
  • TLS using BearSSL
  • (Almost) all memory allocated at startup
    • Only allocations happen while storing received data for parsing.

Supported Protocols

  • HTTP/1.1
  • HTTP/2 (planned)
  • MQTT (planned)
  • Custom, you can write your own

Platform Support

zzz currently focuses on Linux as the primary platform. Windows, MacOS, and BSD support is planned in the near future.

Due to the modular nature, any platform (that works with Zig) can be supported as long as you define an Async backend. This includes embedded and bare metal!

About

A library for writing performant and reliable networked services.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages