iplocpy (IP location Python) is a simple Tornado based web application to determine the location for an IP address. It is based on the free data (city level) available from DB-IP.





	  "status": "OK",
	  "data": {
	    "county": "Beijing",
	    "country": "CN",
	    "range": [
	    "city": "Beijing"


The application is written in Python and uses the Tornado web framework, csv and json modules.

Data source

You need to download the db-ip city database from https://db-ip.com/db/download/city and unpack it.
As of November 2015 the database size is around 50 MB (400 MB unpacked).


The application can use multiple data stores to balance memory consumption, CPU usage and disk space.
Some stats for the November 2015 data set on my Asus UX52VS notebook (10 GB RAM, i7-3517U CPU)


  1. For now the search function is only implemented for IPv4 addresses.
  2. PostgreSQL is about 3x faster at loading the data compared to MongoDB
  3. MongoDB table and index size are about 2.5x - 3x smaller than PostgreSQL (due to using snappy compression)
  4. Using two separate indexes (x and y) PostgreSQL seems to be performing much better than MongoDB (to be analyzed)