I've just deployed my app to a VPS and I'm using Rails 3.1.3, with Ruby 1.9.3-p125, on an apache2 + passenger setup. I'm using the latest gmaps4rails 1.5.2.
When running the application locally I can find locations using gmaps4rails very fast. When I try this on my VPS it takes 60 to 70 seconds. If I remark out the following line then I can submit my form very fast, but no locations are retrieved.
acts_as_gmappable :check_process => false
After it finds the location on the production server it works fine, showing maps and has the correct location stored in the model.
Update
When running my application on the VPS in development mode using WEBrick and running through the same test, it's also slow. This rules out apache2, passenger, and the production environment. I'm starting to think this is an issue with the VPS.
Update
Still trying to find out why it takes a long time to process, I manually used Gmaps4rails in a console on the server like so:
require 'gmaps4rails'
Gmaps4rails.geocode("66 Elizabeth st, Melbourne Victoria Australia")
This took 62seconds, with no error messages.
Update
Read the source code for gmaps4rails and thought that this might be an issue with all http requests
So I used curl to prove this
curl www.google.com.au
This took 63seconds. On my development box it was 2 seconds. Looks like something is delaying my http requests on the server.
Update
Looks like the VPS I'm currently using has had a lot of DOS attacks recently and maybe still experiencing a few. This can increase network latency and packet loss.
gmaps4rails is simply querying google's api to get coordinates from an address.
If this is too slow, consider making the geocode part in background using Gmaps4rails.geocode(address)
.
In this case, disable geocoding on save: acts_as_gmappable :process_geocoding => false