Improve Heroku Geolocation Performance With the GEOLITE2 Buildpack

Recently, we began using IP geolocation within StatusGator to learn where are users are located. We are happy to say that it’s working out well.  We hoped to use these insights to tune our marketing. To that end, we added the Ahoy gem to help collect information related to how our advertising campaigns are going.  The Ahoy gem  also uses the geolocation gem to look up IP addresses.  This significantly increased the number of IP geolocation lookups.  The ahoy readme suggested using the geolite2 city database in order to keep lookups local. No HTTP requests to an external services are required, as lookups use a local database.  This improves performance and prevents us from being subject to API call limits.  One problem is that the database needs to be local to the Rails app, which requires a bit of configuration tweaking when deployed to Heroku.  We created a very basic Heroku buildpack which will download the geolite2 city database into the Ruby on Rails tmp folder.

The performance gains from this have been noticeable, as our background queues do not fill up with HTTP request jobs. The accuracy is certainly good enough for our needs, pinpointing users and visitors to the approximate city from which they are visiting StatusGator.

StatusGator Eats Support Tickets for Lunch

Recent posts