summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2018-01-23 12:19:03 -0800
committerBen Sima <ben@bsima.me>2018-01-23 12:19:03 -0800
commit57bcca93b1ed1e31d8837ba1a43a872c9e4f757f (patch)
treef8af770440fce091cb00a257a32aa96f116d0656
parent4a489e4bff211c424b1c93cfcff214c727d688ad (diff)
add readme
-rw-r--r--readme.md23
1 files changed, 23 insertions, 0 deletions
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..31e0edf
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,23 @@
+1. Have [stack](http://haskellstack.org/) installed
+2. Optional: have [nix](https://nixos.org/nix/) installed. If you *don't* use nix, delete line 3 of `main.hs`.
+3. Run `./main.hs` and the server will startup
+
+To bootstrap the db, do `curl -XPOST "localhost:3000/bootstrap"`.
+
+This takes a while; on my machine it averages 181 records per second. It's IO
+bound, and in an un-optimized program GHC on Linux uses a single, blocking IO
+manager thread (on Windows it's non-blocking, [apparently][1]). This can be
+improved with the [Control.Concurrent][1] module, it which case we could launch
+as many IO threads as we want, and do probably 10k records per second. There's
+definitely an optimal amount of threads here, we'd have to test to find that.
+
+*However*, you can watch it bootstrap. In a separate terminal, do `curl
+"localhost:3000/count"` to see it updating. New POSTs will also work and update
+the database, even while it is bootstrapping, which is kinda cool.
+
+Try this in bash:
+
+ while sleep 1; do curl -s "localhost:3000/count" | jq '.count'; done
+
+
+[1]: https://www.stackage.org/haddock/lts-10.3/base-4.10.1.0/Control-Concurrent.html#g:10