codeforamerica / ohana-api

The open source API directory of community social services.
http://ohana-api-demo.herokuapp.com/api
BSD 3-Clause "New" or "Revised" License
185 stars 344 forks source link

Use QuotaGuard to avoid geocoder rate limits #415

Closed md5 closed 7 years ago

md5 commented 7 years ago

When using Ohana's default settings for the geocoder gem in a Heroku deployment, it is really easy to hit Google's rate limit. This is due to the fact that there is a small pool of outbound IP addresses used by Heroku dynos and Google's rate limiting in the absence of an API key is IP address based.

This PR configures the http_proxy setting for the geocoder library to use the QuotaGuard service if ENV['QUOTAGUARD_URL'] is present. If it is not present, this PR doesn't affect existing behavior. The use of the QuotaGuard Heroku addon with Rails is documented here: https://devcenter.heroku.com/articles/quotaguard#using-with-rails

Since Ohana's documentation for geocoder configuration lives in the wiki, I can update the wiki if this PR is accepted.

coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 99.368% when pulling efcac403a8f412111472f363d79409d3778cdae4 on appropriate:quotaguard into c7d8e0e1bcaf73d2c8632aa65623f108eeff4485 on codeforamerica:master.

monfresh commented 7 years ago

Good find. Thanks!

md5 commented 7 years ago

Do you think it makes sense to update script/setup_heroku to install this add-on automatically?