I have about 100 GPS device sending coordinates periodically on every 10 seconds . My customer want real time reverse geocoding to see his vehicles along with location on a tabular view. I have set up a queue to save all those packets in db before where I have added geocoding script like below
Receive TCP IP message using websocket
public function onMessage(ConnectionInterface $conn, $msg) { //get the message // send the dispatch job to save it in db $this->dispatch(new SavePacketsToDb($key_1, json_encode( array( 'company_id' => $key_1, 'vehicle_id' => $company->vehicle_id, 'tracker_id' => $company->tracker_id, 'lat' => $lat, 'lng' => $lng, 'imei' => $imei, 'datetime' => $datetime, ) )));
}
Run a queue
public function handle(){ $lat=$obj->lat; $lng=$obj->lng; $url = "https://maps.googleapis.com/maps/api/geocode/json?latlng=" . $lat . "," . $lng . "&key=mykey"; $json = file_get_contents($url); $data = json_decode($json); $status = $data->status; $address = ''; if ($status == "OK") { // echo "from geocode address"; echo $address = $data->results[0]->formatted_address; } else{ $address=NULL; } //save to db }
I am just worried if it works for 1000 concurrent devices if I include this geocoding on queue, is there any better approach for it?