Hi,
I've been doing load tests on various servers, including scalatra. My spray test app is based off of this spray routing example
https://github.com/spray/spray/tree/e54d6708c90dbb5ee4b8d7f94b1bad8c42aeb1a2/examples/spray-routing/on-spray-canFor the "Hello World" endpoints that return immediately the performance is virtually identical, but when I add a DB lookup, the equivalent app using scalatra seems to be 2x faster. I'm wondering if the slowness is inherent to spray, or if we're just doing something wrong, being new to spray and actors.
What's the right way to do something like a DB lookup? I've tried just doing it, executing it in a promise with a threadpool, and also in a separate actor spawned like this
val actor = context actorOf Props(new DBLookupActor)
I haven't seen any noticeable performance difference with any of those attempts. There's some subtle stuff hidden behind the scenes, just in terms of which actors get created every request, and how much latency that entails that I don't think is documented beyond the source code. Are the main actors for each request in any sort of pool where they can be reused?
The tests were done via ab -n 5000 -c 100. This was on a linux server, so the mac ab problems I was running into earlier shouldn't apply
Spray:
Concurrency Level: 100
Time taken for tests: 11.077 seconds
Complete requests: 5000
Failed requests: 0
Write errors: 0
Non-2xx responses: 5000
Total transferred: 540000 bytes
HTML transferred: 0 bytes
Requests per second: 451.40 [#/sec] (mean)
Time per request: 221.532 [ms] (mean)
Time per request: 2.215 [ms] (mean, across all concurrent requests)
Transfer rate: 47.61 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.6 0 6
Processing: 24 219 34.9 220 434
Waiting: 24 219 34.9 220 434
Total: 29 220 34.8 221 435
Percentage of the requests served within a certain time (ms)
50% 221
66% 230
75% 237
80% 241
90% 253
95% 269
98% 291
99% 302
100% 435 (longest request)
Scalatra:
Concurrency Level: 100
Time taken for tests: 5.625 seconds
Complete requests: 5000
Failed requests: 0
Write errors: 0
Non-2xx responses: 5000
Total transferred: 7300000 bytes
HTML transferred: 6430000 bytes
Requests per second: 888.87 [#/sec] (mean)
Time per request: 112.502 [ms] (mean)
Time per request: 1.125 [ms] (mean, across all concurrent requests)
Transfer rate: 1267.34 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 18 227.6 0 2998
Processing: 10 94 33.4 88 305
Waiting: 10 93 32.7 88 305
Total: 13 111 230.5 89 3104
Percentage of the requests served within a certain time (ms)
50% 89
66% 103
75% 110
80% 114
90% 127
95% 140
98% 187
99% 298
100% 3104 (longest request)