• This repository has been archived on 25/Jul/2019
  • Stars
    star
    200
  • Rank 189,483 (Top 4 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created about 7 years ago
  • Updated about 5 years ago

Reviews

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

Repository Details

A reasonably complete implementation of the Universal Scalability Law model.

usl4j

CircleCI

usl4j is Java modeler for Dr. Neil Gunther's Universal Scalability Law as described by Baron Schwartz in his book Practical Scalability Analysis with the Universal Scalability Law.

Given a handful of measurements of any two Little's Law parameters--throughput, latency, and concurrency--the USL allows you to make predictions about any of those parameters' values given an arbitrary value for any another parameter. For example, given a set of measurements of concurrency and throughput, the USL will allow you to predict what a system's average latency will look like at a particular throughput, or how many servers you'll need to process requests and stay under your SLA's latency requirements.

The model coefficients and predictions should be within 0.02% of those listed in the book.

Add to your project

<dependency>
  <groupId>com.codahale</groupId>
  <artifactId>usl4j</artifactId>
  <version>0.7.0</version>
</dependency>

It depends on DDogleg Numerics for least-squares regression.

Note: module name for Java 9+ is com.codahale.usl4j.

How to use this

As an example, consider doing load testing and capacity planning for an HTTP server. To model the behavior of the system using the USL, you must first gather a set of measurements of the system. These measurements must be of two of the three parameters of Little's Law: mean response time (in seconds), throughput (in requests per second), and concurrency (i.e. the number of concurrent clients).

Because response time tends to be a property of load (i.e. it rises as throughput or concurrency rises), the dependent variable in your tests should be mean response time. This leaves either throughput or concurrency as your independent variable, but thanks to Little's Law it doesn't matter which one you use. For the purposes of discussion, let's say you measure throughput as a function of the number of concurrent clients working at a fixed rate (e.g. you used wrk2).

After your load testing is done, you should have a set of measurements shaped like this:

concurrency throughput
1 955.16
2 1878.91
3 2688.01
4 3548.68
5 4315.54
6 5130.43
7 5931.37
8 6531.08

For simplicity's sake, let's assume you're storing this as a double[][]. Now you can build a model and begin estimating things:

import com.codahale.usl4j.Measurement;
import com.codahale.usl4j.Model;
import java.util.Arrays;

class Example {
  void buildModel() {
    final double[][] points = {{1, 955.16}, {2, 1878.91}, {3, 2688.01}}; // etc.
  
    // Map the points to measurements of concurrency and throughput, then build a model from them. 
    final Model model = Arrays.stream(points)
                              .map(Measurement.ofConcurrency()::andThroughput)
                              .collect(Model.toModel());
    for (int i = 10; i < 200; i+=10) {
      System.out.printf("At %d workers, expect %f req/sec\n", i, model.throughputAtConcurrency(i));
    }
  }
}

Performance

Building models is pretty fast:

Benchmark         (size)  Mode  Cnt   Score   Error  Units
Benchmarks.build      10  avgt    5   0.507 ± 0.061  us/op
Benchmarks.build     100  avgt    5   1.242 ± 0.266  us/op
Benchmarks.build    1000  avgt    5   7.499 ± 0.157  us/op
Benchmarks.build   10000  avgt    5  72.321 ± 2.681  us/op

Further reading

I strongly recommend Practical Scalability Analysis with the Universal Scalability Law, a free e-book by Baron Schwartz, author of High Performance MySQL and CEO of VividCortex. Trying to use this library without actually understanding the concepts behind Little's Law, Amdahl's Law, and the Universal Scalability Law will be difficult and potentially misleading.

I also wrote a blog post about this library.

License

Copyright © 2017 Coda Hale

Distributed under the Apache License 2.0.

More Repositories

1

sneaker

A tool for securely storing secrets on S3 using Amazon KMS.
Go
802
star
2

metrics

This is not the Java library.
Go
452
star
3

jerkson

[ABANDONED] The Scala applewood bacon to Jackson's chicken breast: JSON cordon bleu.
Scala
280
star
4

shamir

A Java implementation of Shamir's Secret Sharing algorithm over GF(256).
Java
207
star
5

lunk

lunk provides a set of tools for structured logging in the style of Google's Dapper or Twitter's Zipkin
Go
127
star
6

sss

A pure Go implementation of Shamir's Secret Sharing algorithm over GF(256)
Go
103
star
7

http-handlers

Some handy HTTP handlers for Go.
Go
85
star
8

ministat

A small tool to do the statistics legwork on benchmarks etc.
Shell
76
star
9

tinystat

A Go library and CLI tool for evaluating whether two or more sets of measurements are statistically different.
Go
69
star
10

sketchy

A small set of useful probabilistic data structures.
Rust
68
star
11

logula

[ABANDONED] A Scala library which provides a sane log output format and an easy-to-use mixin for adding logging to your code.
Scala
51
star
12

chacha20

A pure Go implementation of the ChaCha20 stream cipher.
Go
46
star
13

charlie

charlie provides a fast, safe, stateless mechanism for adding CSRF protection to web applications.
Go
45
star
14

buster

A Go library which provides a re-usable framework for load-testing things.
Go
43
star
15

fast-uuid

A fast random UUID generator.
Java
41
star
16

rfc6979

A Go implementation of RFC 6979's deterministic DSA/ECDSA signature scheme.
Go
39
star
17

blake2

A BLAKE2 wrapper for Go.
Go
37
star
18

xsalsa20poly1305

A pure Java implementation of XSalsa20Poly1305 authenticated encryption.
Java
34
star
19

aes-gcm-siv

A Java implementation of AES-GCM-SIV (RFC 8452).
Java
33
star
20

jersey-scala

[ABANDONED] A Scala library which adds support to native Scala types in Jersey applications.
Scala
32
star
21

guava-cache-clj

A Clojure wrapper for Guava caches.
Clojure
30
star
22

usl

A Go library and CLI tool which simplifies calculation of Universal Scalability Law parameters given system measurements.
Go
30
star
23

horcrux

A pure Go implementation of security question style password recovery that preserves end-to-end cryptographic security.
Go
28
star
24

soy-clj

An idiomatic Clojure wrapper for Google Closure templates.
Clojure
28
star
25

fig

[ABANDONED] A small Scala library for using JSON-based configuration files.
Scala
27
star
26

time-id

Generates 27-character, time-ordered, k-sortable, URL-safe, globally unique identifiers.
Java
26
star
27

grpc-proxy

A gRPC service which proxies requests to an HTTP server.
Java
25
star
28

chacha20poly1305

An implementation of the chacha20poly1305 AEAD construction.
Go
25
star
29

passpol

A Java library for validating passwords against NIST SP-800-63B requirements.
Java
25
star
30

sskg

A Go implementation of a fast, tree-based Seekable Sequential Key Generator.
Go
24
star
31

pcg.rs

A Rust implementation of the PCG PRNG.
Rust
23
star
32

ruby-gsl

[ABANDONED] New development on the Ruby bindings for the GNU Scientific Library
C
20
star
33

guild

[ABANDONED] Simple, fast actors for Scala.
Scala
20
star
34

xoroshiro.rs

A Rust implementation of the Xoroshiro128+ PRNG.
Rust
19
star
35

colorbot

A Go library which determines the dominant colors in an image.
Go
19
star
36

veil

Veil is an incredibly experimental hybrid cryptosystem for sending and receiving confidential, authentic multi-recipient messages which are indistinguishable from random noise by an attacker.
Rust
19
star
37

docker-rebase

A tool to rebase Docker images.
Go
18
star
38

og

Java
18
star
39

veil-go

Stupid crypto tricks
Go
18
star
40

yellhole

Where else you gonna scream?
Rust
17
star
41

nanostat

A Rust library and CLI tool for evaluating whether two or more sets of measurements are statistically different.
Rust
16
star
42

shore

[ABANDONED] What makes Jersey fun.
Java
16
star
43

yoink

[ABANDONED] A Scala library which wraps Clojure's immutable, persistent collections.
Scala
16
star
44

healthchecks

A Go package which exposes health check results as expvars.
Go
15
star
45

safecookie

A Go library which provides simple, strong protection for cookies.
Go
15
star
46

faster-builder

[ABANDONED] A drop-in replacement for Builder::XmlMarkup which uses libxml for speed and security.
Ruby
15
star
47

cassie

See https://github.com/twitter/cassie for an actual, maintained version.
Scala
15
star
48

emacs.d

My Emacs configuration.
Emacs Lisp
14
star
49

dotfiles

Shell
13
star
50

redact

A Go package which allows you to easily redact sensitive flag values to prevent them from being exposed as expvars or via debugging endpoints.
Go
13
star
51

etm

A Go implementation of AES/CBC/HMAC-based AEAD constructions.
Go
11
star
52

common-pom

A common Maven POM for my various bits of Java software.
11
star
53

aesnicheck

A Go library for checking AES-NI support.
Go
10
star
54

kmssig

A Go utility and library to sign and verify files using AWS’s Key Management Service.
Go
10
star
55

usl-rs

A Rust crate and CLI tool which simplifies calculation of Universal Scalability Law parameters given system measurements.
Rust
9
star
56

reynolds

[ABANDONED] Your serialization format sucks.
Scala
9
star
57

jumphash

A Rust implementation of the Jump Consistent Hash algorithm.
Rust
9
star
58

trove-scala

[ABANDONED] Scala wrappers for the Trove primitive collections.
Scala
9
star
59

hadoop-streaming

[ABANDONED] Support libraries for writing Hadoop Streaming-compatible map/reduce tasks.
Python
8
star
60

balloonhash

A Java implementation of the Balloon Hash algorithm.
Java
8
star
61

ropen

[ABANDONED] A process execution library which doesn't suck.
Ruby
8
star
62

veil-java

Stupid crypto tricks
Java
7
star
63

vlock

[ABANDONED] Vector clocks in Scala
Scala
7
star
64

baconhand

[ABANDONED] A useful slap in the face with baconhand.
Ruby
7
star
65

lockstitch

Lockstitch is an incremental, stateful cryptographic primitive for symmetric-key cryptographic operations (e.g. hashing, encryption, message authentication codes, and authenticated encryption) in complex protocols.
Rust
7
star
66

mocko

A simple mocking library for Clojure.
Clojure
6
star
67

wasp

[ABANDONED] An append-only transaction log for Scala
Scala
6
star
68

kht

A Go implementation of a keyed hash tree.
Go
6
star
69

hrw

A Go implementation of Highest Random Weight hashing.
Go
6
star
70

spritz

A pure Go implementation of the Spritz stream cipher.
Go
5
star
71

u2f-clj

A library for implementing FIDO U2F multi-factor authentication.
Clojure
5
star
72

geoip

A simple Go wrapper for libGeoIP.
Go
5
star
73

totp-clj

A Clojure library for TOTP multi-factor authentication.
Clojure
5
star
74

gimli

A Java implementation of the Gimli cryptographic permutation and hash algorithm.
Java
4
star
75

sss.rs

Shamir’s Secret Sharing for Rust
Rust
4
star
76

longmapper

A bijective mapping for 64-bit integers.
Java
4
star
77

simple_do

[ABANDONED] A simple wrapper around DataObjects.
Ruby
4
star
78

makwa-go

A Go implementation of the Makwa password hashing algorithm.
Go
4
star
79

deyaml

Life’s too short to be a YAML farmer.
Go
4
star
80

hs-shamir

A Haskell implementation of Shamir’s Secret Sharing Scheme over GF(256).
Haskell
4
star
81

tmpmysqld

tmpmysqld allows you to spin up temporary instances of mysqld in Go for testing purposes.
Go
4
star
82

jdbc-perf-wrapper

[ABANDONED] A JDBC performance tracking wrapper.
Java
4
star
83

path_mapper

[ABANDONED] TOTALLY NOT EVEN CLOSE TO WORKING YET. An efficient URL-to-options mapper.
Python
3
star
84

testdb

Go
3
star
85

areion

A Rust implementation of the Areion256 and Areion512 permutations.
Rust
3
star
86

grump

do not use this
Go
3
star
87

voldemort-sets

[ABANDONED] A collection of view classes for the Voldemort key/value store which allow for the storage of sets of numbers.
Java
3
star
88

sfearthquakes

@sfqearthquakes
Java
3
star
89

cpseg

Go
3
star
90

merb_simple_do

[ABANDONED] A Merb plugin for using DataObjects::Simple (simple_do).
Ruby
3
star
91

yrgourd

yrgourd uses Lockstitch to establish mutually-authenticated, forward-secure, confidential, high-performance connections. Like a toy Wireguard.
Rust
3
star
92

aead-stream

Java
3
star
93

zk-cds

Hypothetical design of a zero-knowledge contact discovery system
Rust
3
star
94

xoodoo-p

High-performance, pure-Rust implementation of the Xoodoo-p permutation.
Rust
2
star
95

hudson_deployer

[ABANDONED] A Capistrano-based solution for deploying Java projects from Hudson.
Ruby
2
star
96

gubbins

Go
2
star
97

esi-blog

[ABANDONED] A sample application for playing around with some ESI ideas I had.
Ruby
2
star
98

rsa_pprf

A puncturable PRF based on the RSA accumulator.
Rust
2
star
99

eventflow

A high-throughput, low-latency, GCP-native, analytical event pipeline.
Java
2
star
100

kms-pass

Java
2
star