Recently I ended up in a situation where I needed a library such as this one to do geographical IP lookups, but the assumptions made in this library didn't fit my use-case. More concretely, I wanted to use this library inside an AWS lambda function that, upon receiving a request, would determine where it came from.
The problem here is that, because of the way lambda functions work (they are packaged into containers that are spun up and down for every new request ^[1]) using this package would result in each function having to parse and put all the data into memory just to run a single query against it. In other words, geoip-lite is structured in a way that makes sense for the typical server environment, where the up-front cost of setting up the in-memory store is paid just once and then it's possible to run as many quick lookups as you want, but when the number of lookups is really low that stops being the most optimal structure.
For this reason I decided to build a different package optimized for this use-case, which can be found at onramper/fast-geoip. It uses a pre-built index tree to run O(log n) lookups directly on files. Coupled with some filesystem-based optimisations this has allowed me to get the latency of the first lookup down to 9ms while also lowering memory usage to <1 MB. As you can see, 9ms is way worse than the performance of geoip-lite lookups, but if a process will do fewer than 300/9 ~= 33 lookups, it should be more efficient.
Apart from that, I've set up a CI job that automatically publishes new versions to npm that contain the latest databases from MaxMind. I'm not sure if that's something that would be of interest for you, so for now I've submitted a PR (#210) that only adds basic CI, but if it is please let me know and I'll update my PR with this functionality.
To wrap things up, what are your thoughts on adding a link to my package on this project's readme, along with an explanation stating the niche that it is tailored for? I'm not trying to position my package as a replacement for this (and I belive that I've made it clear on my package's readme) but other people that are looking for something on this specific niche might find it useful.
[1] This is an oversimplification but it's what happens when there's bursty traffic and most invocations hit cold instances.
Recently I ended up in a situation where I needed a library such as this one to do geographical IP lookups, but the assumptions made in this library didn't fit my use-case. More concretely, I wanted to use this library inside an AWS lambda function that, upon receiving a request, would determine where it came from.
The problem here is that, because of the way lambda functions work (they are packaged into containers that are spun up and down for every new request ^[1]) using this package would result in each function having to parse and put all the data into memory just to run a single query against it. In other words,
geoip-lite
is structured in a way that makes sense for the typical server environment, where the up-front cost of setting up the in-memory store is paid just once and then it's possible to run as many quick lookups as you want, but when the number of lookups is really low that stops being the most optimal structure.For this reason I decided to build a different package optimized for this use-case, which can be found at onramper/fast-geoip. It uses a pre-built index tree to run O(log n) lookups directly on files. Coupled with some filesystem-based optimisations this has allowed me to get the latency of the first lookup down to 9ms while also lowering memory usage to <1 MB. As you can see, 9ms is way worse than the performance of
geoip-lite
lookups, but if a process will do fewer than 300/9 ~= 33 lookups, it should be more efficient.Apart from that, I've set up a CI job that automatically publishes new versions to npm that contain the latest databases from MaxMind. I'm not sure if that's something that would be of interest for you, so for now I've submitted a PR (#210) that only adds basic CI, but if it is please let me know and I'll update my PR with this functionality.
To wrap things up, what are your thoughts on adding a link to my package on this project's readme, along with an explanation stating the niche that it is tailored for? I'm not trying to position my package as a replacement for this (and I belive that I've made it clear on my package's readme) but other people that are looking for something on this specific niche might find it useful.
[1] This is an oversimplification but it's what happens when there's bursty traffic and most invocations hit cold instances.