how best to organize the storage container IP addresses (1-3Mb)


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
3 views
for the organization of the cache IP addresses you need a turnkey solution or an efficient algorithm for fast data access ( something like hash tables)
data can become outdated, need to store the last access time.
must be provided for cleaning or replacement not actual data
in this case, better?
frequency of high (200-300 queries per second)!

the solution should be similar to Menkes
fast and efficient!

input IP 32-bit number
the output — no more than 64 bytes of data of fixed size
advanced parameter access time

The goal is to check the last access time.

the options are:
1)
I would not like to elicit information about the IP, to scan the entire table of addresses.
in this case, the insertion of a new IP insert it into the empty slot of the data instead of the first overdue slot.
2)
order by IP because of the high castelnou treatment is not suitable (maybe???).
looking for IP by the method of half-division. If not found — insert. What model storage slots to use in this case?
3)
organizovyvat to turn on access time — it turns out the scan of the whole (parts starting with the first not expired the IP — to him — method of half-marks) in the address table.
appends to the end.

what are the options????
by | 3 views

7 Answers

0 like 0 dislike
To the same data You need to contact in two ways. One way is by IP, the second access time. It is necessary to search data changes (change of IP in the slot data and time of access) is carried out quickly and efficiently.
\r
I would have solved this problem by separating the data itself (an array of slots) from the indexes through which you want to apply. If you take the implementation in C++ something like this:
\r
\r
// The descriptor of the data slot CDataItem struct { __int64 accessTime; // Any idea of time DWORD ip; BYTE userData [64]; }; // The index for the IP std::map ipIndex; // The index access time std::map<__int64, CDataItem *> accessIndex; // Memory to hold an array of slots CDataItem * dataArray = new CDataItem[32000]; 

Of course, after each change (update) of the slot will have to update the indexes.
by
0 like 0 dislike
Don't forget that the IP address is perfectly represented as 4-byte integer.
by
0 like 0 dislike
For a quick search, as an index, you can use the bloom Filter ( en.wikipedia.org/wiki/Bloom_filter )
\r
And Chrome uses bloom filters to estimate whether the website is malicious. In practice, Compact storage million addresses in ~ 18 megabytes.
by
0 like 0 dislike
There is hardly a container that would provide efficient access to data in two indexes. But instead of std::map you can use anything, for example, balanced trees, the more code will be written in C. the Main idea of my proposal is to post the indexes and the data itself. Then the cost of the search slots, insert slots, and updates the indexes, you can try to minimize.
\r
Displacement, too, is fairly simple: at index access time, we find the slot with the minimum value of access time (oldest) and replace it in all fields. Of course, you will have to update both indexes.
\r
Index updates can be done via the delete index entries and add new ones.
by
0 like 0 dislike
and what actually did not fit the description you same memcached?
by
0 like 0 dislike
If standard tools cannot be used, then build a simple binary tree. Great security when you rebuild a separate node.
by
0 like 0 dislike
A mixture of LRU cache and some radix32 tree
by

Related questions

110,608 questions
257,186 answers
0 comments
27,999 users