Forum Discussion
Diego_19194
Nimbostratus
Aug 14, 2007iRule limits
I am writing a iRule where check in a regexp a number in the mail message.
To do that, I used the command matches_regex but when I finished the regexp to add in the iRule, I found it is so big.
Could you tell me what is the regexp limit recommended to use in a iRule?
A text file with all regexp has a size of 500K. I can't upload in the forum because we have a limit of 100K.
16 Replies
- Andy_Herrman_22
Nimbostratus
500K is the size of the regex itself? If that's the case then you probably should use something other than a regular expression for your check.
What exactly are you using the regex for? What is it trying to find/match? There might be a much simpler regex for what you're trying to do (if it's just looking for a particular number then it should be pretty simple). If you can let us know what you're trying to have the regex do I (or someone else here) might be able to come up with a better regex or other solution. - Diego_19194
Nimbostratus
Yes, it is the size. I know is too big, but
The problem is, I have 120K number range and I need to check there if the number in which range match or not.
The number is a MSISDN and I need to find of which operator came.
We are working with some expert people to find the most efficient way to do this regexp and the result was that 500K. We wrote a script that done it.
I was thinking that other way could be check in a file, but I didn't find how can do it. - Andy_Herrman_22
Nimbostratus
I have trouble believing a 500K regex could possibly be the most efficient way to do the search.
You might be able to do something with the matchclass command, but I'm not really familiar with how that works so I'm not sure if it would be any better. - Al_Carandang_11
Nimbostratus
A 500K regex is large. Maybe if you post a small part of the regex like the first hundred or so characters we could see how it could be rewritten (if at all possible)
-Al - Diego_19194
Nimbostratus
I attached a small range of this rules.
Once is the number range and once the regexp.
Thanks,
Diego - Andy_Herrman_22
Nimbostratus
Your ranges look like they can be compressed, potentially by a lot.
For instance, take this snippet:
005491140300000-005491140309999
005491140310000-005491140319999
005491140330000-005491140339999
005491140340000-005491140349999
005491140350000-005491140359999
005491140360000-005491140369999
005491140370000-005491140379999
That could simply be this:
005491140300000-005491140379999
There are some gaps in the range, but in general they could probably be compressed a lot more.
Given that the data appears to be just numbers, not text, it would probably be a lot faster to convert the value you get to a number, and then have some if statements that check that number to see if it's within any of the valid ranges. This would be a ton faster than trying to use a ginormous regex.
Pseudocode (cause I don't feel like writing TCL right now) for a couple random ranges I grabbedlong value = extractValueFromRequest(); if( (value > 5491140300000 && value < 5491140379999) || (value > 5491144230000 && value < 5491144299999) ) { doStuff(); } else { reject(); }
If you need to do something different for each of those ranges, and aren't just looking to see if it's a valid range I think it would still go a lot faster to convert to a number and check against the ranges than try to do regexes. Numeric operations are much faster than string operations. - Diego_19194
Nimbostratus
Remember that it is a simple example and my script fix this problem explained for you.
Yes, are you right that I can do that, but if I have 170K range yet, where I can't do that.
Then I must write 170K if statement. I think it is not good to the LTM about performance.
Can I have some option to do that reading an external file? - Andy_Herrman_22
Nimbostratus
170k if statements that are doing simple numerical checks are probably going to be much faster than an 500k regular expression (which would probably be executing a lot more than 170k if statements while executing).
Either way, the performance is probably going to be pretty bad, but I wouldn't be surprised if using numeric operations end up being at least an order of magnitude faster.
That said, it really sounds like this is something that should be done at more of an application level than a network level. - Kirk_Bauer_1018
Nimbostratus
And 170k if statements are probably too big as well. I'd say they would be 100 times more efficient than a regexp of that size, maybe even 1000 times. But ultimately I would spend your efforts on finding a better solution, maybe at the application level itself, or maybe by explaining to us what you are trying to do and seeing if there is a drastically easier method of doing what you want to do.
You may be able to define a data class with the ranges and then loop through that data class doing numerical comparisons, for example. - Deb_Allen_18Historic F5 AccountPerhaps the larger issue is that a human will have to manually evaluate the list's current incarnation to realize the potential of concatenating the blocks into the desired concise mapping of MSISDN to provider.
I was recently asked to use an iRule to determine the country of origin for each connection based on a commercially available list of IPs by country code. The list was very comprehensive, but contained netmasks of every shape and size, some contiguous, some not. There were also gaps in the data, some significant, some not. We could certainly have written an iRule to make the appropriate comparisons if only the customer could have provided the base data in nice neat blocks.
Same problem here, I think.
/deb
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects