graylog2-server icon indicating copy to clipboard operation
graylog2-server copied to clipboard

MongoDB LUT - CIDR Lookup performance issues

Open rich-graylog opened this issue 1 year ago • 3 comments

Summary from a customer call:

MongoDB Lookup Table Download and Cache - Like with CSV files, pull the mongodb lookup table on an interval (like every hour) and cache it for in-memory lookups. They had a CIDR table that was 1916 rows and even with a long running cache it saturated a 10GbE link because CIDR queries are filtered at Graylog and not MongoDB so it had to pull the full table each time there was a cache miss.

If possible, we should look at ways of optimizing performance when the cache is not updated and we need to retrieve from Mongo again.

rich-graylog avatar Jan 06 '25 17:01 rich-graylog

We may not be able to improve performance dramatically given the nature of how these lookups are performed - will need to discuss with architecture if they have alternate solutions.

rich-graylog avatar Jan 27 '25 19:01 rich-graylog

@rich-graylog I think I may actually have a good solution to make this more efficient, will take a look at it soon

kingzacko1 avatar Jan 28 '25 15:01 kingzacko1

I created a stress test with CSVFileDataAdapter to test the performance improvement. I made a 10,000 entry CIDR data adapter and then performed 10,000 lookups against it. With my original logic the lookups took about 105 seconds. With the new data structure implementation it took about 6 seconds.

MongoDB lookups are only slightly more complex with the following changes from CSV Files:

  • ability to add/remove lookups: this one isn't a huge issue
  • option of having a TTL on each entry: this requires a little more effort, but should still be okay

kingzacko1 avatar Jan 28 '25 21:01 kingzacko1