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 lookup 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 request 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, pin pointing users and visitors to the approximate city from which they are visiting StatusGator.