-
Notifications
You must be signed in to change notification settings - Fork 292
Poor performance with modsecurity enabled #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Ok, I disabled modsec_audit.log and now it seems better the more requests I send :) (only tested with Nginx+)
|
Hi @mimugmail, @zimmerle, I have created a separate repository that can be used to easily spin up reproducible environments (thanks goes to Vagrant and SaltStack) suitable for running benchmarks against nginx with libmodsecurity connector module: https://github.com/defanator/modsecurity-performance It also can be extended to include more sophisticated things, if anyone would like to. For now I'm seeing more than 4x performance drop when libmodsecurity is turned on without any actual rules configured, and more than 170x performance drop when libmodsecurity is turned on with OWASP CRS v3.0.0 loaded (I'm not including any absolute numbers here for obvious reasons; you can find my own results in the repo - I'll add a bit more details about the hardware used as well). Main goal is to give an ability for anyone to easily reproduce the tests against particular combination of libmodsecurity, ModSecurity-nginx connector module, and nginx. |
@mimugmail - can I ask you to share your modsecurity.conf you were using while testing? (if it differs from the default one here - https://github.com/SpiderLabs/ModSecurity/blob/master/modsecurity.conf-recommended) |
|
@mimugmail, @zimmerle, I've spent some time running simple benchmarks on multi-core VM, and found something interesting about https://github.com/defanator/modsecurity-performance/wiki#2017-03-05 |
@mimugmail, I've just updated your comments to get proper formatting for preformatted text (commands output) - JFYI. |
@defanator Thanks :) Just did a copy+paste. This behavior fits perfectly with my measurements. Have you already tried concurrent logging? SecAuditLogType Concurrent But performance is still around 144req/s |
Hi @mimugmail and @defanator, Do you mind to test the branch v3/dev/speedup? I did some performance improvements on v3/dev/speedup. There are space for more, but it will be good to count in your tests to confirm that I am on the right track. Oh btw, please give it a try with the SecAuditLog disabled, going to look into the audit log generation tomorrow. |
@zimmerle, please check https://github.com/defanator/modsecurity-performance/wiki#2017-03-10 I ran a few cycles with However, in the worst case (full OWASP CRS v3.0.0 is loaded) average RPS is more than 10% greater, and latency is more than 10% lower than in previous run (
|
With SecAuditEngine On `root@nginx:/opt# ab -n 10000 -c 20 -k http://127.0.0.1:80/ Benchmarking 127.0.0.1 (be patient) Server Software: nginx/1.11.9 Document Path: / Concurrency Level: 20 Connection Times (ms) Percentage of the requests served within a certain time (ms) Benchmarking 127.0.0.1 (be patient) Server Software: nginx/1.11.9 Document Path: / Concurrency Level: 20 Connection Times (ms) Percentage of the requests served within a certain time (ms) WIth SecAuditEngine Off results are the same ... |
@mimugmail @defanator thanks! @mimugmail how many workers do you have? |
@zimmerle meeep you got me, now it's 100 (was 1) 👍 SecAuditEngine Off: `root@nginx:/opt# ab -n 10000 -c 20 -k http://127.0.0.1:80/ Benchmarking 127.0.0.1 (be patient) Server Software: nginx/1.11.9 Document Path: / Concurrency Level: 20 Connection Times (ms) Percentage of the requests served within a certain time (ms) `SecAuditEngine On: `root@nginx:/opt# ab -n 10000 -c 20 -k http://127.0.0.1:80/ Benchmarking 127.0.0.1 (be patient) Nginx 1.11.9, 4GB RAM, 4 CPUs Also with just 1000: `root@nginx:/opt# ab -n 1000 -c 20 -k http://127.0.0.1:80/ Benchmarking 127.0.0.1 (be patient) |
@mimugmail Great! Thanks ;) |
@mimugmail, running 100 workers on 4-core machine serving CPU-heavy load (like ModSecurity) won't lead to any benefits. I don't see much sense in setting Also, your latest results do not include any summary for |
@defanator Yep, I set it to 4, no difference. Funny thing is that between 1000 and 10000 checks it always stucks at the last 105. With just 100 I get: |
the branch v3/dev/speedup was merged into v3/master. |
2G KVM VPS 1vcore
|
A couple of benchmarks with recent libmodsecurity sources: https://github.com/defanator/modsecurity-performance/wiki#2017-04-11-1 (single worker), https://github.com/defanator/modsecurity-performance/wiki#2017-04-11-2 (multi worker). Noticeable improvement is that multi-worker setup does not lock all the processing inside single worker (as it was before [1]), so I was able to reach almost 1k RPS with the full OWASP CRS v3.0.0 loaded, with 6 workers. [1] https://github.com/defanator/modsecurity-performance/wiki#2017-03-05 |
I am closing this issue in favor of @defanator wiki. I would encourage you guys to keep the work monitoring the performance. whenever you find a problem with it, please re-open this issue. |
@defanator did you get a chance to re-run the benchmark again? |
@luengnat I run it periodically, just updated the results page with most recent build here: https://github.com/defanator/modsecurity-performance/wiki#2017-12-11 |
anyone have ideal for solving this problem. I'm using v3 |
As suggested within issues owasp-modsecurity/ModSecurity#1318 I'll open a new one here. With MS enabled with the current codebase the performance test with "ab" from apache2-utils is not going over 300req/s.
With a virtual machine on Virtualbox with 4 cores and 4gb ram:
And without:
I tested this also with Nginx+ but then the tool stucks a 90%, no mather how many requests (20 cores and 64GB ram):
But with just 100 it's ok:
Perhaps others can post their results too.
Ah, I also tried to disable logging but it doens't affect the performance at all.
The text was updated successfully, but these errors were encountered: