• Stars
    star
    115
  • Rank 305,916 (Top 7 %)
  • Language
    Haskell
  • License
    MIT License
  • Created about 10 years ago
  • Updated about 9 years ago

Reviews

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

Repository Details

A dead simple networked key/value store

Neks

A dead simple key/value server

Neks is an in-memory networked key/value server written in ~200 lines of Haskell.

It is intended to be very easy to modify.

Features
  • Very simple
  • Pretty fast (>1M transactions per second is easy, see Benchmark)
  • Highly concurrent
  • Atomic transactions (e.g. atomic read-and-swap)
  • Optional disk persistence (with atomic snapshotting)
To install using Cabal:
cabal install neks
NeksServer <opt-args>
NeksClient <args>
To build and run from source (recommended):
cabal sandbox init
cabal install --only-dependencies
cabal run NeksServer
cabal run NeksClient -- <args>

or, with dependencies installed:

ghc -O2 -threaded Network/Neks/NeksServer.hs
ghc -O2 -threaded Network/Neks/NeksClient.hs
./Network/Neks/NeksServer +RTS -N<number of cores>
./Network/Neks/NeksClient <args>

To run the Python client:

python3 Client.py
To view instructions:
NeksServer --help
NeksClient --help
Benchmark:

The server and client run on two cores. The client runs

  • 50 threads
  • 200 requests per thread
  • 50 reads and 50 writes per request

Speed depends on latency and bandwidth. Here's what I get on my home machines:

Avg. Latency Transactions / Second
.1ms (localhost) 1,150,000
.3ms (ethernet) 1,100,000
3.5ms (wireless) 750,000
Protocol:

All network encoding is done using msgpack.

Messages are preceded by the length of the message, transmitted as a 64-bit big-endian unsigned integer.

The client sends requests to the server, and the server responds with the results of the requests.

There are 4 kinds of requests:

  • Requests to Get key K. These are formatted as [0, K]. The server sends a response.
  • Requests to Set key K to value V. These are formatted as [1, K, V]. The server does not send a response.
  • Requests to Delete key K. These are formatted as [2, K]. The server does not send a response.
  • Requests to Atomically evaluate a list of requests R. This is formatted as [3, R]. The server sends the response as if all requests in R had been evaluated normally.

There are 2 kinds of responses:

  • Response that the value V for requested key K was found. This is formatted as [-1, V].
  • Response that the value for requested key K was not found. This is formatted as [-2].

Example conversation:

Client: <message length>[[1,"status","OK"],[0,"Jim"],[0,"Dwight"]]
Server: <message length>[[-1,"Halpert"],[-1,"Schrute"]]

More Repositories

1

MicroMechBoard

Source files and schematics for a very small, 33-key mechanical keyboard
Eagle
299
star
2

LEDStrip

An LED music visualizer
C
74
star
3

Example-Distributed-App

An example distributed systems application in Haskell using Cloud Haskell
Haskell
69
star
4

CPU

CPU Building Tutorial
Haskell
50
star
5

HaSKI

Cλash/Haskell FPGA-based SKI calculus evaluator
Verilog
47
star
6

PythonEyeDetection

Detects eyes, irises, and pupils
Python
42
star
7

vumeter

A nixie tube audio meter
C++
18
star
8

ManyBSTs

Simple Binary Search Trees in a bunch of languages
Elixir
10
star
9

Callsigns

A program that generates available 5-digit callsigns that look like English words
Haskell
10
star
10

metastrip

Utility for stripping image metadata
Haskell
10
star
11

zfs-backup

A simple tool for backing up and rotating ZFS snapshots
Haskell
9
star
12

Lambda16

A 16-bit microprocessor implemented in Cλash/Haskell
Haskell
8
star
13

Bitcoin-HD-wallet-generator

Code for creating BIP0032 HD wallets, as well as deriving public addresses without the private key.
Python
6
star
14

astro

Astrophotography
Jupyter Notebook
5
star
15

HNet

Neural Network
Haskell
5
star
16

hacktx-proveme

A bitcoin proof-of-existence/cryptographic timestamping server for the 2013 HackTX 24 hour hackathon
Python
5
star
17

Lambda17

The successor to Lambda16. Now using multiple functional units.
Haskell
4
star
18

smap

Set and map operations for the command line
Haskell
3
star
19

FastPush

Fast push monad in Haskell
Haskell
2
star
20

Frequencies

Playing around with image compression
Jupyter Notebook
2
star
21

mhacks_messageinabottle_server

Python
2
star
22

TeensyRNG

A USB Random Number Generator based off the Teensy microcontroller platform
C
2
star
23

htmx-haskell-hello

Haskell
1
star
24

SystemNFC

Various LibNFC functions wrapped in C++
C++
1
star
25

NDFSMtoFSM

A Haskell library for converting NDFSMs to FSMs
Haskell
1
star
26

shamir

Simple Shamir's Secret Sharing Scheme
Haskell
1
star
27

BlackHole

Accurately ray tracing a black hole using Haskell
Haskell
1
star
28

dalloc

Messing around with storage
Haskell
1
star
29

Dist

A Haskell library for probability distributions
Haskell
1
star