Speeding up Python with Rust: GeoIP Lookup Database as a case study.
Abhijit Gadgil (~gabhijit) |
Description:
In order to perform GeoIP Lookup, there are databases like maxmind available, which allow one to map an IP address to a given country. In this talk we explore an approach to implement such a database using first principles in Python and then take a look at how this implementation can be speeded up using Rust and Python bindings for the Rust library using pyo3
.
The talk is organized into following three sections -
Overview of GeoIP Database Lookup Implementation (5 minutes)
- Internet, Autonomous Systems and BGP Updates
- Publicly available datasets, to obtain the required data that is -
- Prefix data
- Autonomous Systems to Organizations and Organizations to Country Data.
- Routing Table and Longest Prefix Match
Implementation of above routing table and other utils in Rust with available Pythonic APIs and performance comparison (20 minutes)
- An implementation of a Routing Table to perform longest prefix match for an Input IP Address in Python (And using
numpy.dtype
) - Same implementation in Rust with Python Bindings
- pybgpkit_parser (public PyPI package)
- route_table ( We will discuss in details this implementation)
- An implementation of a Routing Table to perform longest prefix match for an Input IP Address in Python (And using
Performance Comparison of the two approaches (5 minutes)
Audience should expect to understand the following -
- Understand about how internet works
- Basic implementation of parsing structured data in Python (python struct module)
- Simple implementation of Longest Prefix Match and a routing table.
- An overview of Rust and
pyo3
.
Prerequisites:
None. This is an intermediate level talk with lot of Python (and Rust) code. The aim is also not to provide a tutorial on pyo3
per se. But we will touch upon enough intro to help understand the code.
Content URLs:
Public Datasets
- Routeviews for the BGP RIB data
- Caida for Autonomous Systems data.
Code
Slides
Speaker Info:
Software developer with experience at several layers of abstraction. Python is my GoTo language to experiment with ideas and Rust is my most favorite language. I have been a speaker at previous Pycon India conferences. I work as a freelance software developer through my consultancy company hyphenOs Software Labs
Speaker Links:
Links to slides for my previous Pycon Talks
- Call, Raise or Fold running poker simulations in Python.
- Python and
cffi
visualizing network traces
Social Links: