PHP Curl Performance Bottleneck Making Google Maps Geocoding Requests PHP Curl Performance Bottleneck Making Google Maps Geocoding Requests curl curl

PHP Curl Performance Bottleneck Making Google Maps Geocoding Requests


some things I would do:

  • no matter how "premium" you are, doing external http-requests will always be a bottleneck, so for starters, cache request+response - you can still update them via cron on a regular basis

  • these are single http requests - you will never get "fullspeed" with them especially if request and response are that small (< 1MB) - tcp/handshaking/headers/etc.so try using multicurl (if your premium allows it) in order to start multiple requests - this should give you fullspeed ;)

  • add "Connection: close" in the request header you send, this will immediately close the http connection so your and google's server won't get hammered with halfopen


Considering you are running all your requests sequentially you should look into dividing the work up onto multiple machines or processes. Then each can be run in parallel. Judging by your benchmarks you are limited by how fast each Curl response takes, not by CPU or bandwidth.

My first guess is too look at a queuing system (Gearman, RabbitMQ).