You don't show your patterns, but I suspect they are a large part of the problem.
You will want to look for a new question here (I am sure it has been asked) or elsewhere for detailed advice on building fast regular expression patterns.
But I find the best advice is to anchor your patterns and avoid runs of unknown length of all characters.
So instead of a pattern like path/.*/.*\.js
use one with a $
on the end to anchor it to the end of the string. That way the regex engine can tell immediately that index.html
is not a match. Otherwise it has to do some rather complicated scans with path/
and .js
possibly showing up anywhere in the string. This example of course assumes the file name is at the end of the log line.
Anchors work well with start of line patterns as well. A pattern might look like ^[^"]*"GET /myfile"
That has a unknown run length but at least it knows that it doesn't have to restart the search for more quotes after finding the first one. The [^"]
character class allows the regex engine to stop because the pattern can't match after the first quote.