stanaka/go-rest-api-server — pull request #1 by maoe (2013-10-18 09:51:49+00:00)
Title: The REST server implementation in Haskell

I ported the golang server to Haskell. I haven't took any performance profiling yet, so there should be plenty of room for optimization. I think it's already fast as it is, though.

The Haskell server outperformed the Perl server in all cases on my laptop (MacBook Pro Mid 2010).

Haskell:

```
[maoe@maoe:~/src/go-rest-api-server on haskell-wai]
% plenv exec perl bench.pl -t http -h http://localhost:9000/ -c 1
Target: http://localhost:9000/
Concurrency Level: 1
Time taken for tests: 5.776 seconds
Num of requests: 10000
Requests per second: 1731.44 [#/sec] (average)
Time per request: 0.578 [ms] (average)
[maoe@maoe:~/src/go-rest-api-server on haskell-wai]
% plenv exec perl bench.pl -t http -h http://localhost:9000/ -c 10
Target: http://localhost:9000/
Concurrency Level: 10
Time taken for tests: 4.173 seconds
Num of requests: 10000
Requests per second: 2396.59 [#/sec] (average)
Time per request: 0.417 [ms] (average)
[maoe@maoe:~/src/go-rest-api-server on haskell-wai]
% plenv exec perl bench.pl -t http -h http://localhost:9000/json -c 1
Target: http://localhost:9000/json
Concurrency Level: 1
Time taken for tests: 5.434 seconds
Num of requests: 10000
Requests per second: 1840.34 [#/sec] (average)
Time per request: 0.543 [ms] (average)
[maoe@maoe:~/src/go-rest-api-server on haskell-wai]
% plenv exec perl bench.pl -t http -h http://localhost:9000/json -c 10
Target: http://localhost:9000/json
Concurrency Level: 10
Time taken for tests: 4.205 seconds
Num of requests: 10000
Requests per second: 2378.19 [#/sec] (average)
Time per request: 0.420 [ms] (average)
[maoe@maoe:~/src/go-rest-api-server on haskell-wai]
% plenv exec perl bench.pl -t http -h http://localhost:9000/mem -c 1
Target: http://localhost:9000/mem
Concurrency Level: 1
Time taken for tests: 4.738 seconds
Num of requests: 10000
Requests per second: 2110.67 [#/sec] (average)
Time per request: 0.474 [ms] (average)
[maoe@maoe:~/src/go-rest-api-server on haskell-wai]
% plenv exec perl bench.pl -t http -h http://localhost:9000/mem -c 10
Target: http://localhost:9000/mem
Concurrency Level: 10
Time taken for tests: 3.432 seconds
Num of requests: 10000
Requests per second: 2913.83 [#/sec] (average)
Time per request: 0.343 [ms] (average)
[maoe@maoe:~/src/go-rest-api-server on haskell-wai]
% plenv exec perl bench.pl -t http -h http://localhost:9000/mem.json -c 1
Target: http://localhost:9000/mem.json
Concurrency Level: 1
Time taken for tests: 4.739 seconds
Num of requests: 10000
Requests per second: 2110.11 [#/sec] (average)
Time per request: 0.474 [ms] (average)
[maoe@maoe:~/src/go-rest-api-server on haskell-wai]
% plenv exec perl bench.pl -t http -h http://localhost:9000/mem.json -c 10
Target: http://localhost:9000/mem.json
Concurrency Level: 10
Time taken for tests: 3.368 seconds
Num of requests: 10000
Requests per second: 2968.75 [#/sec] (average)
Time per request: 0.337 [ms] (average)
```

Perl:

```
[maoe@maoe:~/src/go-rest-api-server on haskell-wai]
% plenv exec perl bench.pl -t http -h http://localhost:5000/ -c 1
Target: http://localhost:5000/
Concurrency Level: 1
Time taken for tests: 7.158 seconds
Num of requests: 10000
Requests per second: 1396.94 [#/sec] (average)
Time per request: 0.716 [ms] (average)
[maoe@maoe:~/src/go-rest-api-server on haskell-wai]
% plenv exec perl bench.pl -t http -h http://localhost:5000/ -c 10
Target: http://localhost:5000/
Concurrency Level: 10
Time taken for tests: 7.258 seconds
Num of requests: 10000
Requests per second: 1377.87 [#/sec] (average)
Time per request: 0.726 [ms] (average)
[maoe@maoe:~/src/go-rest-api-server on haskell-wai]
% plenv exec perl bench.pl -t http -h http://localhost:5000/json -c 1
Target: http://localhost:5000/json
Concurrency Level: 1
Time taken for tests: 7.413 seconds
Num of requests: 10000
Requests per second: 1349.03 [#/sec] (average)
Time per request: 0.741 [ms] (average)
[maoe@maoe:~/src/go-rest-api-server on haskell-wai]
% plenv exec perl bench.pl -t http -h http://localhost:5000/json -c 10
Target: http://localhost:5000/json
Concurrency Level: 10
Time taken for tests: 6.341 seconds
Num of requests: 10000
Requests per second: 1577.15 [#/sec] (average)
Time per request: 0.634 [ms] (average)
[maoe@maoe:~/src/go-rest-api-server on haskell-wai]
% plenv exec perl bench.pl -t http -h http://localhost:5000/mem -c 1
Target: http://localhost:5000/mem
Concurrency Level: 1
Time taken for tests: 6.659 seconds
Num of requests: 10000
Requests per second: 1501.71 [#/sec] (average)
Time per request: 0.666 [ms] (average)
[maoe@maoe:~/src/go-rest-api-server on haskell-wai]
% plenv exec perl bench.pl -t http -h http://localhost:5000/mem -c 10
Target: http://localhost:5000/mem
Concurrency Level: 10
Time taken for tests: 4.355 seconds
Num of requests: 10000
Requests per second: 2296.17 [#/sec] (average)
Time per request: 0.436 [ms] (average)
[maoe@maoe:~/src/go-rest-api-server on haskell-wai]
% plenv exec perl bench.pl -t http -h http://localhost:5000/mem.json -c 1
Target: http://localhost:5000/mem.json
Concurrency Level: 1
Time taken for tests: 6.066 seconds
Num of requests: 10000
Requests per second: 1648.52 [#/sec] (average)
Time per request: 0.607 [ms] (average)
[maoe@maoe:~/src/go-rest-api-server on haskell-wai]
% plenv exec perl bench.pl -t http -h http://localhost:5000/mem.json -c 10
Target: http://localhost:5000/mem.json
Concurrency Level: 10
Time taken for tests: 4.871 seconds
Num of requests: 10000
Requests per second: 2052.86 [#/sec] (average)
Time per request: 0.487 [ms] (average)
```