• Stars
    star
    405
  • Rank 106,656 (Top 3 %)
  • Language
    Erlang
  • License
    Other
  • Created over 12 years ago
  • Updated over 11 years ago

Reviews

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

Repository Details

A Cowboy Websocket demo

wsdemo

A Websocket competition. Will your favorite platform come out on top? If you think your platform of choice was poorly represented, "submit a pull requestโ„ข"

How do you include a contestant?

Just create the "Hello, World!" of socket servers, an echo server that speaks WebSocket version 13 (13 is the only version my client supports).

First write your implementation in place it in the competition/ directory.

Added any instructions needed to install dependencies in configure_ubuntu-12.04.sh. Add any build instructions to competition/Makefile if your project needs to be compiled

wsdemo_bench utilizes supervisord to start and stop the servers while running the tests. In order to include your server in the test you need to create a supervisord ini file in competition/servers.

[program:%(server_name)s]
command=%(command)s
autostart=false
autorestart=false
startretries=0
stopasgroup=true
killasgroup=true

The server name must follow the following format:

{language}-{platform}

For instance if you wrote an echo server using bash and nc the server name would be bash-nc. You can add additional demarcations if needed. For instance the Python tornado example has a single threaded version and a multiprocessor version which go by the name python-tornado-1 and python-tornado-N.

Next, you need to add your server to the server list in wsdemo_bench.app.src configuration file.

Finally, add yourself to the AUTHORS file; you've earned it.

Running the benchmark

It is best to run the benchmark client on a separate machine than the servers.

Using two brand new Ubuntu 12.04 servers, run the configure_ubuntu-12.04.sh script on each. This script will destructively alter each server so use caution and review the script before running it.

If you want to use a different OS, use configure_ubuntu-12.04.sh as a template for configuring your system of choice.

Next compile the code on both machines:

  make

To run a single benchmark on a server do the following:

./runtest db_path duration hostname port client_count

For instance for a benchmark of 192.168.1.5:8000 of 1000 clients lasting 60 seconds with with the data stored at data/myserver the command would be:

./runtest data/myserver 60 192.168.1.5 8000 1000

Running the entire suite on your own servers

There are two components in wsdemo_bench. The first component is supervisord

wsdemo_bench communicates with Supervisord to start and stop each server before each benchmark.

On the machine that you are running the servers on do the following:

sudo bash
ulimit -n 999999
cd competition
supervisord

You can monitor supervisord by using the supervisorctl command:

competition/ $ supervisorctl status

Next, on the client machine create a config/small-scale.config file:

[
    {sasl, [
        {sasl_error_logger, {file, LogFile}}]},

    {wsdemo_bench, [
                {host, Ip},
                {port, 8000},
                {db_root, DbRoot},
                {clients, 100},
                {seconds, 10},
                {supervisord, {ServerHost, 9001}}]}].

Replace LogFile, Ip, DbRoot and ServerHost with the correct values. Ensure that both the path to LogFile and the path to DbRoot exist or the test will crash.

This configuration file describe a test using 100 clients for 10 seconds each test. We will use this smaller test to ensure that all the servers start and stop properly.

To run this benchmark, do the following:

sudo bash
ulimit -n 999999
./bin/run_all_tests.sh -config config/small-scale.config

If all goes well, you should see the suite running in front of your eyes. Let that run for the entire test. It should run for 12 minutes or so.

If any of the servers crashes you can do the following to diagnose the cause:

competition/ $ supervisorctl tail $SERVER_NAME stderr

After the small scale test, it is time to run the full scale test:

[
    {sasl, [
        {sasl_error_logger, {file, LogFile}}]},

    {wsdemo_bench, [
                {host, Ip},
                {port, 8000},
                {db_root, DbRoot},
                {supervisord, {ServerHost, 9001}}]}].

Suite config

Here is the full spec for the wsdemo_bench config:

 [
    {host, Host :: string()},
    {port, Port :: integer()},
    {db_root, DbRoot :: directory()},
    {supervisord, {Host, 9001}},
    {clients, number()}, % defaults to 10000
    {seconds, number()}, % defaults to 600
    {servers, [ServerName1::string(), ..., ServerNameN::string()]} % defaults to full suite
 ]        

Exporting the data

The resulting leveldb databases will be placed in your configured db_root. The events are stored as binary Erlang terms in the database so you will need to export the events to use them.

There are two scripts to do that. ./bin/compile_all_stats.sh and ./bin/convert_all_stats.sh

./bin/compile_all_stats.sh creates three .csv tables:

  • counts.csv - the sums of all the events
  • handshake_times.csv - timestamp, elapsed usecs for each handshake
  • message_latencies.csv - timestamp, elapsed usecs for each message

./bin/convert_all_stats.sh dumps the raw events as a events.csv table.

The events data has the following fields:

timestamp, type, client_id, event_key, event_data
  • timestamp - The timestamp of the event
  • type - the server type
  • client_id - A string that identifies the client
  • event_key - The event type
  • event_data - event specific data

The event_data is used to pair ws_init and ws_onopen events to calculate the elapsed handshake time and the event_data is used to pair send_message events to recv_message events to calculate the elapsed message time. The event_data for 'EXIT' events take the format of {pid(), Reason :: any()}. These are some of the expected reasons for a client crash:

connection_timeout - The client could not establish a connection
                     with the server in under 2 seconds
normal - The server closed the connection.  This should never
         happen for this benchmark

Any reason other than these are an unexpected error and should be reported as an issue. If you see a {error, Reason} you should probably file a bug report as well unless you can determine it is a server issue.

More Repositories

1

crdt

CRDT toolbox
Python
203
star
2

riak_crdt

A Riak loader for CRDTs
Python
21
star
3

node-jsonld-dsl

A DSL for building JSON-LD resources
JavaScript
15
star
4

flask-auth

Flask-Auth
Python
13
star
5

erl-crdt

A Collection of Conflict Free Replicated Datatypes
Erlang
13
star
6

flaskcma

A revolutionary content management application made with Flask and MongoEngine
Python
9
star
7

blog

My pelican blog
HTML
7
star
8

wsgirouter

A dead simple WSGI router
Python
6
star
9

collection-protobuf

A draft spec of collection+protobuf for evolving, typed HATEOAS RESTful services.
6
star
10

rafterl

An experimental implementation of the Raft consensus algorithm
Erlang
5
star
11

comp-sci-papers

A repository of public computer science papers
5
star
12

doze

Easy URL creation.
Python
5
star
13

micromodelsext-riak

An extension to micromodels to fetch/store/delete models in Riak
Python
4
star
14

timetracker

A singe-user time tracking web service
Python
4
star
15

edotsandboxes

A Dots and Boxes game written in Erlang and HTML5
Erlang
4
star
16

package-virtualenv

A virtualenv packager
Python
4
star
17

riak_pipetest

An example of a stand alone riak_pipe app
Erlang
3
star
18

hydra-python-client

A low-level hydra client for python
Python
3
star
19

dict-to-protobuf

Convert a dict to a protobuf message
Python
3
star
20

pitchfork-reviews

Fetches the top pitchfork reviews
Haskell
3
star
21

home-infra

Nix
3
star
22

pyqueryextract

Uses pyquery based DSL to turn HTML into a dictionary
Python
3
star
23

python-kestrel

A Kestrel python client that is built specifically for Kestrel instead of piggybacking on python-memcache
Python
3
star
24

duplicator-i3-repetier-firmware

Duplicator i3 Repetier Firmware for RAMPS 1.4
C++
2
star
25

ubuntu-natty-web

Ubuntu Natty -> Web Node installer
Shell
2
star
26

restexperiments

experiments to test the assertions made by REST and ROA
Python
2
star
27

fp

A FP toolkit for Python
Python
2
star
28

python-ldf-server

An experimental ldf-server for python
Python
2
star
29

erl-twitterlinks

A twitter link processer
Erlang
2
star
30

tvservice

A simple web service that filters a RSS feed based on simple pattern matching.
Python
2
star
31

nanoweb

The nano web framework.
Python
2
star
32

linked-data-and-rest

Python
2
star
33

feedservice

feedservice provides a webservice to store RSS feeds
Python
2
star
34

x-dhall-helm-release

Experimental Dhall Flux Helm Release support for Flux's helm-operator
Nix
1
star
35

gawkercheck

Quick python script to see if your email address was exposed by their breach
Python
1
star
36

doterlang_lib

My ~/.erlang_lib configuration
Shell
1
star
37

hyperblog

An experiment with the concept of hypermedia transclusion
JavaScript
1
star
38

pebble-vaper

A pebble app for vapers
C
1
star
39

x-tvservice-clj

A port of a my tv show
Clojure
1
star
40

redditpic-html5

An HTML5 app to browse pictures on reddit
1
star
41

experiments

My Experimental Code
Python
1
star
42

paginateanything

Paginate anything.
Python
1
star
43

gittest

Testing git
1
star
44

djsonld

Django tools for JSON-RD
1
star
45

OctoPrint-Queue

A print queue plugin for octoprint
Python
1
star
46

arbeiter

An unassuming work queue system
Python
1
star
47

clj-txtbudget

Experiment/Education port of my txtbudget app
Clojure
1
star
48

violet

An experimental Python DSL for validation
Python
1
star
49

docker-dev

experimentation with docker as a dev environment
Shell
1
star
50

node-fantasy-express-resource

Fantasy Land Express Resources
JavaScript
1
star
51

simplox

An experimental "CaaS"
Erlang
1
star
52

spark-experiments

Some Apache Spark experiments
Python
1
star
53

pci-mapreduce

Examples of the application of O'Reilly Programming Collective Intelligence + Map Reduce
JavaScript
1
star
54

txtbudget

A text based budget planning tool
Python
1
star
55

x-knifepicker

A tool for me to find a Swiss Army Knife
Erlang
1
star
56

python-manifestor

A simple project manifest tool
Python
1
star
57

pmap

a pmap implementation for Python
Python
1
star
58

play-instathread

A port of my instathread application
Scala
1
star
59

washingmachine

My project to make my dumb washing machines into a smart washing machine
C++
1
star