fast-geoip | memory replacement for geoip-lite , a node library
kandi X-RAY | fast-geoip Summary
kandi X-RAY | fast-geoip Summary
This library provides an interface to efficiently query MaxMind's GeoLite databases, which contain geolocation information for IPs. Concretely, this was created as an alternative to geoip-lite that adapts better to use-cases where either a low memory footprint is needed, not many IPs will be examined through the library or a high start-up overhead is unacceptable. Concretely, what geoip-lite does is that, on startup, it reads the whole database from disk, parses it and puts it all on memory, thus this results in the startup time being increased by about ~233 ms along with an increase of memory being used by the process of around ~110 MB, in exchange for any new queries being resolved with low sub-millisecond latencies (~0.02 ms). This works if you have a long-running process that will need to geolocate a lot of IPs and don't care about the increases in memory usage nor startup time, but if, for example, your use-case requires only geolocating a single IP, these trade-offs don't make much sense as only a small part of the satabase is needed to answer that query, not all of it. This library tries to provide a solution for these use-cases by separating the database into chunks and building an indexing tree around them, so that IP lookups only have to read the parts of the database that are needed for the query at hand. This results in the first query taking around 9ms and subsequent ones that hit the disk cache taking 0.7 ms, while memory consumption is kept at around 0.7MB. Wrapping it up, geoip-lite has huge overhead costs but sub-millisecond queries whereas this library doesn't have any overhead costs but its queries are slower (0.7-9 ms). And, without further addo, here's a code snippet of library usage (note that this library uses promises instead of synchronous functions, this is the only difference between this library and geoip-lite). Finally, to add some historical context, this library was originally built with the idea of using it for a lambda container that had to geolocate the IP of the current request, something that turned out to be impossible to do with geoip-lite because memory consumption exceeded the 126MB limit and it slowed down the lambda function by over 200ms just to query a single IP.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Generate a location file
- Extract location attributes
- Store content in data directory
- Parse a number
- Jsonify an object
- Generate list of blocks for blocks of blocks
- Extract block attributes
- Store the first IP address into the index
- Convert an IP address to an integer
- Generate index
- Remove old data files
- Store dynamic params
- Delete a directory
fast-geoip Key Features
fast-geoip Examples and Code Snippets
Community Discussions
Trending Discussions on fast-geoip
QUESTION
I have geoiplookup installed on Centos 7 and I'd like to select an IP from a mysql table and then get the location of an IP address from the command line.
For example, I can type ! geoiplookup' 123.45.36.35 in mysql and get the city, country, etc.
I could download the data from MaxMind and then upload it to mysql and run a query as mentioned on this site or this site but I do not want to maintain and update another table monthly. Is this the best solution?
This link shows several python examples that I have used in fail2ban logs.
Id like to do something like this:
...ANSWER
Answered 2018-Jan-02 at 20:35As you mention, if you want to use the geoiplookup utility and keep up-to-date IP info you would need to periodically (monthly), download and maintain the IP updates from MaxMind (with a cron job).
What you may want to do instead is to call the curl
utility, and retrieve data from the super cool ipinfo.io website:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install fast-geoip
You can use fast-geoip like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page