Hello,
we are using ancient webrick version for smart-proxy and due to Ruby 2.0 and long-term plans to SCL smart-proxy, we are stuck on this version. Webrick does not appear to close inactive connections rendering itself to an easy DoS target, it’s performance is also not great. More on this topic at:
And
It looks like Smart Proxy boots fine on Puma which is small, fast, scalable and up-to-date Rack compatible HTTP(s) server with zero Ruby dependencies and few basic C dependencies (like openssl), so packaging should be easy.
I propose to add support for Puma in Smart Proxy launcher but still not dropping webrick from its dependencies and making it opt-in for few releases to allow good fallback option. Although puma offers both threading and forking architecture, we need to start with just single worker because current ruby code is thread safe but does not take into account there can be multiple instances (e.g. inotify threads etc). Support for multiple workers is out of scope of this effort.
Things to test:
- Start, stop, restart
- Logging, log file rotation
- Signals
- Log buffer
- Inotify leases monitor
- Plugin authors (announcement, ask for testing)
I’ve tested that Puma closes inactive connections correctly which gives better results against preventing from slow DoS attacks.
Quick and dirty test via Apache “ab” tool, 1000 requests with concurrency of 8. Webrick:
[lzap@box ~]$ ab -n 5000 -c 8 http://127.0.0.1:8448/features
Document Path: /features
Document Length: 128 bytes
Concurrency Level: 8
Time taken for tests: 11.567 seconds
Complete requests: 5000
Failed requests: 0
Total transferred: 1640000 bytes
HTML transferred: 640000 bytes
Requests per second: 432.26 [#/sec] (mean)
Time per request: 18.507 [ms] (mean)
Time per request: 2.313 [ms] (mean, across all concurrent requests)
Transfer rate: 138.46 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 2 18 8.5 17 69
Waiting: 1 13 7.2 12 53
Total: 2 18 8.5 17 69
Percentage of the requests served within a certain time (ms)
50% 17
66% 21
75% 23
80% 25
90% 30
95% 34
98% 40
99% 44
100% 69 (longest request)
Puma:
[lzap@box ~]$ ab -n 5000 -c 8 http://127.0.0.1:9292/features
Document Path: /features
Document Length: 128 bytes
Concurrency Level: 8
Time taken for tests: 3.713 seconds
Complete requests: 5000
Failed requests: 0
Total transferred: 1165000 bytes
HTML transferred: 640000 bytes
Requests per second: 1346.57 [#/sec] (mean)
Time per request: 5.941 [ms] (mean)
Time per request: 0.743 [ms] (mean, across all concurrent requests)
Transfer rate: 306.40 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 1 6 3.4 5 30
Waiting: 0 3 1.1 2 10
Total: 1 6 3.4 5 30
Percentage of the requests served within a certain time (ms)
50% 5
66% 6
75% 7
80% 8
90% 10
95% 12
98% 15
99% 18
100% 30 (longest request)
Puma appears to be 3.1x faster in handling /features
API call than Webrick. This is naive test which aims to measure performance of the web server stack, in real world requests most of the time is spent in waiting for (network) IO but it gives the picture about efficiency of the middleware.