-
Notifications
You must be signed in to change notification settings - Fork 282
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
nginx connector is terribly slow on parsing JSON request body #89
Comments
Hmm did anyone get anywhere with this? As i'm experiencing it too |
That may or may not be related to #104. |
I am not able to reproduce the same results with the latest version of libModSecurity + nginx-connector. That is what I've got:
Using the upload app from @defanator's vagrant with this payload. Can you double check with the latest version? @defanator @vikas027 @Stono Thank you. |
@defanator @vikas027 @Stono ping.... I would love to hear from you how do you feel about the JSON timings on this newest v3 release. IMHO we can proceed to close this issue. But, you may have a different test case scenario in mind. |
@zimmerle I'll resurrect this topic early next week and will do some tests with real payloads provided to us earlier. Will keep you posted. |
@zimmerle I'm getting around 6 seconds for a POST request with ~170k JSON payload, while previously it was leading to endless loop and CPU hog on a single worker. I think we're good here now. |
Thank you @defanator and everybody who provided me feedback via email. Based on @defanator's comment I am closing the issue. |
hey @zimmerle , |
Environment details:
Payload: ~15kb JSON output from http://demo.nginx.com/status (publicly available demo server).
Request:
Results: nginx worker consumes 100% CPU, the above request takes a while to process (I wasn't able to get any response within ~5 minutes, then cancelled curl).
I have gathered a profile from running worker with
perf record
and it showed that the worker process was spinning in a loop ofngx_http_modsec_pcre_malloc()
andngx_pfree()
(called fromngx_http_modsec_pcre_free()
):Corresponding source code entries:
https://github.com/SpiderLabs/ModSecurity-nginx/blob/master/src/ngx_http_modsecurity_pre_access.c#L198-L200
I disabled PCRE malloc workaround in this particular place with the following patch:
This improved overall picture a lot:
Perf profile now contains the real reason of slowness:
I also prepared a couple of flamegraphs for both scenarios:
http://pp.nginx.com/defan/preaccess-palloc.svg
http://pp.nginx.com/defan/preaccess-malloc.svg
I'm not sure that this should be addressed in connector though. My understanding is that
pcre_compile()
/pcre_study()
may be called just once for every regex from CRS, leavingpcre_exec()
in runtime, while currently all of those are being called in runtime for every rule/comparison.@zimmerle @victorhora appreciate your feedback here - TIA!
The text was updated successfully, but these errors were encountered: