Skip to content
Notifications
Clear all

Help: Custom rules are tanking our site performance.

5 Posts
5 Users
0 Reactions
0 Views
(@data_shipper_joe)
Honorable Member
Joined: 3 months ago
Posts: 387
Topic starter   [#24918]

Hey everyone, hope you're having a data-filled day. I'm usually over in the data integration threads talking Fivetran vs. Airbyte, but today I need to tap into the community's WAF wisdom.

We've been using Imperva for a while now, and overall it's been solid for the standard OWASP stuff. Where we've really leaned into it, though, is creating custom rules for some very specific API endpoints. Think along the lines of complex input validation, specific business logic blocks (like preventing certain state transitions via POST requests), and geo-blocking with some extra conditions.

The problem is, we've started to see some pretty significant latency spikes. It's directly correlated to when these heavier custom rules kick in. A normal request might breeze through in ~50ms, but when it triggers one of these rule chains, we're seeing it balloon to 500ms+ sometimes. It's starting to affect user experience on some critical paths.

Here's a sanitized example of the *type* of rule that seems to be causing the most pain:

```xml

Complex_State_Validation
Block

/api/v1/order/updateState

REQUEST_ARGS
Contains
REFUNDED

REQUEST_HEADERS
Contains
Referer: https://internal-admin.example.com
Lowercase

REQUEST_METHOD
Equals
POST

REQUEST_BODY
ContainsRegex
"status":"PENDING_SHIPMENT"

```

It's the combination of checking headers, body content, and arguments that seems to be the killer. We're not even using regex heavily, but the mere inspection of the request body on a high-traffic endpoint is adding up.

Has anyone else run into this? How did you diagnose the specific bottleneck? I'm wondering if:
- Splitting this into multiple, simpler rules would be better.
- Moving some of this logic (like the business state validation) *behind* the WAF into the app itself is smarter.
- We're just hitting a resource limit on our Imperva plan.

Any performance tuning tips or real-world experiences would be hugely appreciated. I love the control these rules give us, but not at the cost of making our site feel slow.

ship it


ship it


   
Quote
(@amandaf)
Reputable Member
Joined: 3 weeks ago
Posts: 237
 

Yeah, that example rule is your problem. You're running regex on every request argument for a state transition check, which is a huge computational hit. The WAF is doing a ton of string parsing it wasn't really designed for efficiently.

You've moved business logic into the security layer. That's always going to be expensive. Those checks for state validity belong in your application code, not in the WAF. The WAF should be your outermost guard for threats, not your data integrity enforcer.

What's your actual goal with that rule? Stopping fraud? If so, you might need a different tool downstream, not a WAF custom rule.


—AF


   
ReplyQuote
(@charlesb)
Estimable Member
Joined: 3 weeks ago
Posts: 158
 

Complex input validation and state transition logic belong in your application code, not in a regex soup at the WAF layer. You're paying a latency tax for architectural convenience.

It's the classic vendor trap. They sell you the feature - "write any rule you want!" - without mentioning the performance cost is entirely yours to bear. You've essentially built a poorly optimized middleware service at the edge, and you're billed for the privilege of running it slowly.

What's your actual throughput on these endpoints? I'd bet the cost of those 500ms hits, in cloud compute terms, would pay for moving that logic into a proper app service ten times over.


Beware of free tiers


   
ReplyQuote
(@cloud_cost_hawk)
Estimable Member
Joined: 2 months ago
Posts: 147
 

You're spot on about the cost angle. That "poorly optimized middleware service at the edge" line nails it. You're paying Imperva's premium to run your own inefficient code.

Moving that logic to the app layer isn't just about performance, it's a cost optimization. Those 500ms hits at edge scale mean you're burning money on WAF compute units for something a couple of cheap application containers could handle more efficiently. The latency is just the symptom, the bill is the disease.

What's the per-request cost on that WAF tier? I guarantee it's higher than your app's compute cost per request. They never show you that math when they demo the custom rule builder.


cost optimization, not cost cutting


   
ReplyQuote
(@gracep)
Estimable Member
Joined: 3 weeks ago
Posts: 163
 

Exactly. The WAF is optimized for pattern matching against known attack signatures, not executing business logic trees. Every custom regex evaluation forces a full parser pass on the payload, which is expensive at scale.

If the goal is fraud prevention, you need a dedicated service. A WAF rule can't maintain session state or calculate velocity across requests. It's a stateless, pattern-based filter.

What's the hit rate on this rule? If it's blocking even 1% of traffic, that's still 1% of all requests paying a 500ms tax for a check that belongs in-app.


Data over opinions


   
ReplyQuote