Hi,
My situation is as follows:
I have a list of (all) ip prefixes with assigned AS numbers. I aggregated them, so there are ~120000 of them (prefixes, not as numbers :) ). I need to look them up real quick (meaning - I tell it an individual IP address and want to get a number of AS it is in), so I use Net::Patricia and it does the job well, but...
I have multiple processes using the data, and multiple machines running the same processes. As the data takes ~20MB in memory, it's a little inconvenient to multiply it more than 100 times.
So I thought: MEMCACHE. Or something like this. But it seems that memcache is actually suitable for simple key-value assignments, and I have no idea how I could use it to store my Net::Patricia object.
So - my questions are:
- Is there a way to store what I already have in memcache or any other type of cache, and share it among processes (and, preferably, machines)?
- If not - what would be a good way to cache ip prefixes with as numbers? Where good means: speed efficient (less than one second lookup times!) and easily cachable, preferably in memcache, but a 'host only' cache would be acceptable. Size is of no importance (since it's going to be shared, so additional couple of megs makes no real difference) as long as it's at least "imaginable" - a hash of hashes with all IPs in the world isn't ;).
Let's assume an sql-database is not an option here. Nor is rbldnsd and dns txt queries.
Thanks in advance,
Daniel
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.