Also as @mtmail mentions, the better path for this is probably not on the device itself. It would get expensive where N number of users is really high. Perhaps at the service layer, send the device location to the service, and have the service return the nearby users.