• Stars
    star
    151
  • Rank 244,102 (Top 5 %)
  • Language
    Haskell
  • License
    Other
  • Created about 2 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A drop-in replacement for nix-serve that is faster and more reliable

nix-serve-ng

nix-serve-ng is a faster, more reliable, drop-in replacement for nix-serve.

Quick start

There are two main approaches you can use to upgrade a NixOS system to replace the old nix-serve with nix-serve-ng.

If you specify your desired NixOS system within flake.nix then you can do something like this:

{ inputs = {
    nixpkgs.url = github:NixOS/nixpkgs;

    nix-serve-ng.url = github:aristanetworks/nix-serve-ng;
  };

  outputs = { nixpkgs, nix-serve-ng, ... }: {
    nixosConfigurations.default = nixpkgs.lib.nixosSystem {
      modules = [
        nix-serve-ng.nixosModules.default

        { services.nix-serve.enable = true;

          …
        }
      ];

      system = "x86_64-linux";
    };
  };
}

If you don't use flake.nix then you can instead define your NixOS module: like this:

let
  nix-serve-ng-src = builtins.fetchTarball {
    # Replace the URL and hash with whatever you actually need
    url    = "https://github.com/aristanetworks/nix-serve-ng/archive/1937593598bb1285b41804f25cd6f9ddd4d5f1cb.tar.gz";

    sha256 = "1lqd207gbx1wjbhky33d2r8xi6avfbx4v0kpsvn84zaanifdgz2g";
  };

  nix-serve-ng = import nix-serve-ng-src;

in
  { ... }: {
    imports = [ nix-serve-ng.nixosModules.default ];

    …
  }

Motivation

Our requirements for this project were:

  • Improve reliability

    … since nix-serve would intermittently hang and require restarts

  • Improve efficiency

    … since nix-serve was doing some obviously inefficient things which we felt we could improve upon

  • Be backwards-compatible

    Our replacement would need to be a drop-in replacement for the original nix-serve, supporting the same command-line options and even sharing the same executable name

    The only exception is logging: we provide more detailed logging than before

Did we satisfy those requirements?

Results

  • Reliability

    We have test-driven this internally under heavy load with stable memory usage and without any failures but it's probably premature to declare victory.

    In particular, we have not done the following things:

    • Memory leak detection

      In other words, we haven't put our nix-serve through, say, valgrind

    • Exploit detection

      In other words, we haven't attempted to crash or sabotage the service with maliciously-crafted payload

  • Performance

    We have improved significantly on efficiency, not only compared to nix-serve but also compared to other nix-serve rewrites. We are more efficient than:

    • The original nix-serve

    • eris - A Perl rewrite of nix-serve

    • harmonia - A Rust rewrite of nix-serve

    See the Benchmarks section below for more details

  • Backwards-compatibility

    We have excellent backwards-compatibility, so in the vast majority of cases, you can simply replace pkgs.nix-serve with pkgs.nix-serve-ng and make no other changes.

    • Our executable shares the same name (nix-serve) as the original program

    • We support most the original command-line options

      The options that we're aware of that we do not currently support fall into two categories:

      • Useless options which are only relevant to starman:

        Upon request, we can still parse and ignore the following irrelevant options for extra backwards compatibility:

        • --workers

          We do not use worker subprocess like starman does. Instead we use warp which internally uses Haskell green threads to service a much larger number of requests with less overhead and lower footprint when idle.

        • --preload-app

          This optimization is meaningless for a compiled Haskell executable.

        • --disable-proctitle

      • Useful options

        We might accept requests to support the following options, but we might explore other alternatives first before supporting them:

        • --max-requests

          warp itself is unlikely to be a bottleneck to servicing a large number of requests but there may still be Nix-specific or disk-specific reasons to cap the number of requests.

        • --disable-keepalive

        • --keepalive-timeout

        • --read-timeout

        • --user

        • --group

        • --pid

        • --error-log

    Because of this backwards-compatibility you only need to replace the old nix-serve executable with the nix-serve executable built by this package (which is what the included NixOS module does).

    You don't need to define or use any new NixOS options. You continue to use the old services.nix-serve options hierarchy to configure the upgraded service.

Benchmarks

The test environment is a large server machine:

  • CPU: 24 × Intel(R) Xeon(R) CPU E5-2680 v3 @ 2.50GHz
  • RAM: 384 GB (24 × 16 GB @ 2133 MT/s)
  • Disk (/nix/store): ≈4 TB SSD

Legend:

  • Fetch present NAR info ×10: Time to fetch the NAR info for 10 different files that are present
  • Fetch absent NAR info ×1: Time to fetch the NAR info a single file that is absent
  • Fetch empty NAR ×10: Time to fetch the NAR for the same empty file 10 times
  • Fetch 10 MB NAR ×10: Time to fetch the NAR for the same 10 MB file 10 times

Raw numbers:

Benchmark nix-serve eris harmonia nix-serve-ng
Fetch present NAR info ×10 2.09 ms ± 66 μs 41.5 ms ± 426 μs 1.57 ms ± 91 μs 1.32 ms ± 33 μs
Fetch absent NAR info ×1 212 μs ± 18 μs 3.42 ms ± 113 μs 139 μs ± 11 μs 115 μs ± 6.2 μs
Fetch empty NAR ×10 164 ms ± 8.5 ms 246 ms ± 20 ms 279 ms ± 10 ms 5.16 ms ± 368 μs
Fetch 10 MB NAR ×10 291 ms ± 8.7 ms 453 ms ± 19 ms 487 ms ± 41 ms 86.9 ms ± 3.0 ms

Speedups (compared to nix-serve):

Benchmark nix-serve eris harmonia nix-serve-ng
Fetch present NAR info ×10 1.0 0.05 1.33 1.58
Fetch absent NAR info ×1 1.0 0.06 1.53 1.84
Fetch empty NAR ×10 1.0 0.67 0.59 31.80
Fetch 10 MB NAR ×10 1.0 0.64 0.60 3.35

We can summarize nix-serve-ng's performance like this:

  • Time to handle a NAR info request: ≈ 100 μs
  • Time to serve a NAR: ≈ 500 μs + 800 μs / MB

You can reproduce these benchmarks using the benchmark suite. See the instructions in ./benchmark/Main.hs for running your own benchmarks.

Caveats:

  • We haven't used any of these services' tuning options, including:
    • Tuning garbage collection (for nix-serve-ng)
    • Tuning concurrency/parallelism/workers
  • We haven't benchmarked memory utilization

More Repositories

1

avd

Arista Validated Designs
Python
270
star
2

purescript-backend-optimizer

Optimizing backend toolkit and modern ECMAScript backend for PureScript
PureScript
198
star
3

goarista

Fairly general building blocks used in Arista Go code and open-sourced for the benefit of all.
Go
197
star
4

EosSdk

EOS SDK - write native apps for your Arista switch
C++
147
star
5

netdevops-examples

Examples of using DevOps tools with Arista EOS and CloudVision
Jupyter Notebook
116
star
6

bst

A one-stop shop for process isolation
C
99
star
7

openmgmt

Documentation and examples for using open network management tools such as OpenConfig
Go
68
star
8

ansible-cvp

Ansible modules for Arista CloudVision
Python
66
star
9

j2lint

Jinja2 Linter CLI
Python
52
star
10

anta

What do you call an ant with frogs legs?
Python
46
star
11

cvprac

Python
45
star
12

goeapi

Go library for Arista's eAPI command API implementation
Go
43
star
13

CloudVisionPortal-Examples

A collection of CloudVision Portal examples and best practices
Python
40
star
14

yang

YANG models published and supported by Arista Networks
Makefile
36
star
15

ctypegen

Generate ctypes boilerplate code from debugging information; Use python to mock C code for testing
Python
28
star
16

cloudvision-python

Python resources and libraries for integrating with Arista's CloudVision platform
Python
25
star
17

atd-public

Python
24
star
18

sonic

Open source drivers and initialization library for Arista platforms running SONiC
Python
22
star
19

cloudvision

Resources and documentation for Arista's CloudVision platform
TypeScript
21
star
20

openconfigbeat

Elastic Beat for OpenConfig
Go
21
star
21

puppet-eos

Arista EOS modules for automating network resources using Puppet
20
star
22

avd-workshops

Arista Automation Workshop
CSS
18
star
23

eoscentral

Code examples associated with EOS Central articles.
17
star
24

cloudvision-apis

gRPC APIs for integrating with Arista's CloudVision platform
16
star
25

robotframework-aristalibrary

Robot Framework library for Arista EOS
Python
16
star
26

terraform-provider-cloudeos

Arista CloudEOS Terraform Provider
Go
14
star
27

vane

A weather vane is an instrument used for showing the direction of the wind. Just like a weather vane, Vane is a network certification tool that shows a network's readiness for production based on validation tests.
Python
12
star
28

arista-ceoslab-operator

K8s operator for managing meshnet-networked cEOS-lab instances
Go
11
star
29

CloudEOS

HCL
11
star
30

swi-tools

Scripts for handling Arista SWI and SWIX files
Python
11
star
31

cloudvision-ztpaas-utils

Utilities for ZTP as a Service with CloudVision
Python
11
star
32

terraform-provider-cloudvision

Go
10
star
33

cloudvision-go

Go resources and libraries for integrating with Arista's CloudVision platform
Go
10
star
34

cloudvision-python-actions

Example Python action scripts for integrating with Change Controls in Arista's CloudVision platform
Python
9
star
35

arcomm

A command-line utility and library for communicating with Aristas
Python
9
star
36

ci-workshops-fundamentals

Network automation fundamentals repository to deliver fundamentals workshops.
Jinja
8
star
37

pytest-netdut

A pytest library for testing software on network devices.
Python
7
star
38

arista-onie-installer

ONIE installer for Arista's EOS
6
star
39

pyopenconfig

Python implementation of the gRPC service for interacting with network devices based on OpenConfig models (DEPRECATED)
Python
6
star
40

telegraf-cloudvision

Go
5
star
41

cloudeos-k8s

Documentation and YAML files for CloudEOS for Kubernetes
Smarty
5
star
42

eos-eapi-rust

Rust
5
star
43

dom

The Digital Optical Monitor script will periodically poll the optical power levels of each interface on a switch and generate syslog events when the transmit (Tx) or Receive (Rx) power levels change beyond the threshold. Optionally, SNMP v2c traps or v3 informs may be generated, as well.
Python
5
star
44

go-cvprac

Go
4
star
45

eos_boot_loader

Shell
4
star
46

training-infra-public

Arista training lab infrastructure
Python
4
star
47

ansible-eos

Ansible modules for Arista Network's EOS
Python
4
star
48

quantumfs

A distributed FUSE filesystem optimized for large-scale software development
Go
4
star
49

gomap

Golang hash map with user provided hash and equal functions
Go
4
star
50

telemetry-email-alerter

Python script that allows you to subscribe to Arista Telemetry Events and then send them to an SMTP server for email notifications.
Python
3
star
51

eos-deployment-guide-configs

Configs from EOS Deployment Guides
3
star
52

switch-interface-maps

This is a set of interface maps (json) for as many SKUs (DC and Campus) to be used in conjunction with the Arbitrary Interface Mapping feature
3
star
53

net-snmp

Arista Networks' net-snmp patches
C
3
star
54

pcapinspect

Python
3
star
55

openfdk

Open FPGA Developer's Kit
VHDL
3
star
56

ServiceNowRac

ServiceNow RESTful Client
Python
3
star
57

aql-examples

Sharing AQL (Advanced Query Language for CVP) examples with customers
Python
3
star
58

ownership-voucher-grpc

2
star
59

chef-eos

Chef cookbook for Arista EOS.
Ruby
2
star
60

sonic-firmware

SONiC Firmware
2
star
61

docker-logstash

Container for logstash with input from the kafka feed from Arista's OpenConfig client
2
star
62

aclabs

Python
2
star
63

cloudvision-frontend-config

JavaScript, TypeScript and Eslint configuration for CloudVision frontend libraries.
JavaScript
2
star
64

ci-workshops-avd

AVD workshop repository to deliver workshop content specific to AVD.
Makefile
2
star
65

promtail_extension

Python
1
star
66

eos-external-tools

Go
1
star
67

probe-tools

Some test tools for RFC8335 PROBE aka ICMP Extended Echo
Python
1
star
68

tech-library-comments

1
star
69

eossdkrpc

EOS SDK RPC protobuf files and information
1
star
70

quicktrace-public

The open source version of QuickTrace
C++
1
star
71

python-aristaproto

Python
1
star