Re: tcpsvd - Allow only x connections from somebody/hour
Laurent Bercot <[email protected]>
| Newsgroups | gmane.comp.misc.pape.general |
|---|---|
| Message-ID | <[email protected]> |
> here you need counting, which sounds "sequential". if you just add entries > "somewhere" dropping least recently used ones, you get organisational overhead > (linking all info related to a particular IP, traversing the structure). this > service ought to rely and benefit from a simple hash table keeping just a few > items. KISS. I did some experiments a while ago, when I wanted to implement my own tcpserver with a per-IP connection limit, with three different data structures to store the per-IP information: a "flat" array, an AVL tree, and a hash table. The flat array became significantly slower when the number of connections my test program was keeping track of reached something like 5000. In "normal" use, you won't have more than 500 connections at the same time, maybe 1000. There's no reason to use complex, heavier and more bug-prone data structures if a linear search takes so little time. -- Ska