1 year ago

Processing Millions of Records

Posted 1 year ago by geetpurwar

I need to send push notifications to millions of records. I am using following method. Wondering if there is better way to do it.

$merged_collection = new Collection;
foreach($segmentArray as $singleSegment){
$merged_collection =        $merged_collection>merge(segmented_subscribers($singleSegment, false, false));

$chunk = $merged_collection->chunk(200);
foreach($chunk as $subscribers){
    foreach($subscribers as $subscriber){
        if(! in_array($subscriber->id, $sentArray)){
            $subscription = Subscription::create([
                    'endpoint' => $subscriber->endpoint,
                    'publicKey' => $subscriber->publicKey,
                    'authToken' => $subscriber->authToken,

            if($webPush->sendNotification($subscription, $payload, true)){
            array_push($sentArray, $subscriber->id);
            array_push($failedArray, $subscriber->id);

Please sign in or create an account to participate in this conversation.