Facing EC2 high CPU utilization while sending Bulk Notifications

I’m using Aws SQS with my Laravel project in which when membership owner create a post in memebership I’m sening Twilio SMS, Email and Firebase push Notifications to all the subscriber of that membership. I’m using Laravel Queue Job to send this notifications. The issue is one membership has 5000+ subscribers so it becomes 15000+ notifications so when my server is processing this requests CPU utilization is going 99% for short period of time and users are getting 500 internal server error from nginx.

Post Creation Queue Dispatch

$membershipSubscriberIdsChunk = $membershipSubscriber->pluck("id")->chunk(30)->toArray();

                    foreach ($membershipSubscriberIdsChunk as $key => $chunk) {
                        dispatch(new SendPostMailNotificationJob($chunk, $mailPost, $membershipTitle, 0))->onQueue("post-email");
                        dispatch(new SendPostPushNotificationJob($chunk, $mailPost->user->name))->onQueue("post-firebase");
                        dispatch(new SendPostSMSNotificationJob($chunk, $mailPost->user->name))->onQueue("post-sms");
                    }

Twilio SMS

$recipients = $fans->filter(function ($item) {
                if ($item->receive_sms && isset($item->phone) && $item->phone) {
                    $countrycode = $item->country_code ?? '+1';
                    $phone = preg_replace("/[^0-9]/", "", $item->phone);
                    $phone = substr($phone, -10);
                    if ($phone) {
                        $item->phoneNumber = $countrycode . $phone;
                        return $item;
                    }
                }
            })->pluck("phoneNumber")->toArray();

            $message = "$this->creatorName has added a new post.";
            $messageOptions = [
                'from' => config('services.twilio.from_number'),
                'body' => $message,
            ];
            Log::channel("post_sms")->info("Twilio SMS Notification Process Start at " . Carbon::now()->format("Y-m-d H:i:s"));
            $twilio = new Client(config('services.twilio.sid'), config('services.twilio.auth_token'));
            foreach ($recipients as $key => $recipient) {
                try {
                    Log::channel("post_sms")->info("$key SMS Start");
                    $twilioResponse = $twilio->messages->create($recipient, $messageOptions);
                    Log::channel("post_sms")->info("$key [$recipient] SMS Done.");
                } catch (Exception $e) {
                    Log::channel("post_sms")->error("$recipient has an error." . $e->getMessage());
                }
            }
            Log::channel("post_sms")->info("Twilio SMS Notification Process Completed at " . Carbon::now()->format("Y-m-d H:i:s") . ".n");

            return response()->json([
                "message" => "Sent Request to Twilio."
            ]);

Firebase Push Notification

$subscribers = MembershipSubscriber::with(["fan"])->whereIn("id", $this->membershipSubscriber)->get();
        Log::channel('post_firebase')->info("Firebase Notification Process Start at " . Carbon::now()->format("Y-m-d H:i:s"));
        $message = $this->creatorName . " has added a new post.";
        $title = "New Post Added";

        if ($subscribers->count()) {
            foreach ($subscribers as $key => $subscriber) {
                if (isset($subscriber->fan) && isset($subscriber->fan->apn_token) && $subscriber->fan->apn_token != "") {
                    $optionBuilder = new OptionsBuilder();
                    $optionBuilder->setTimeToLive(60 * 20);

                    $notificationBuilder = new PayloadNotificationBuilder($title);
                    $notificationBuilder->setBody($message)->setSound('default');

                    $dataBuilder = new PayloadDataBuilder();
                    $dataBuilder->addData(['subscriber_id' => $subscriber->id, 'type' => 'post']);

                    $option = $optionBuilder->build();
                    $notification = $notificationBuilder->build();
                    $data = $dataBuilder->build();

                    $token = $subscriber->fan->apn_token;
                    $downstreamResponse = FCM::sendTo($token, $option, $notification, $data);
                    $responseData = [
                        "numberSuccess" => $downstreamResponse->numberSuccess(),
                        "numberFailure" => $downstreamResponse->numberFailure(),
                        "numberModification" => $downstreamResponse->numberModification(),
                    ];
                    Log::channel('post_firebase')->info("response for token.", $responseData);
                }
            }
            Log::channel('post_firebase')->info("Firebase Notification Process Completed at " . Carbon::now()->format("Y-m-d H:i:s") . "n");
            return response()->json([
                "message" => "Push Notifications sent successfully"
            strong text]);
               

Email

$fans = MembershipSubscriber::with(["fan"])->whereIn("id", $this->membershipSubscriber)->get()->pluck("fan");
        $fans = $fans->where("receive_email", 1);
        if ($fans->count()) {
            Log::channel('post_mail')->info("Mail Notification Main Job Start at " . Carbon::now()->format("Y-m-d H:i:s"));
            Notification::send($fans, (new PostCreatedEmailNotification($this->membershipPost, $this->membershipTitle, $this->jobDelay)));
            Log::channel('post_mail')->info("Mail Notification Main Job Completed at " . Carbon::now()->format("Y-m-d H:i:s") . ".n");
        } else {
            Log::channel('post_mail')->error("Mail Notification Fan User Not Found.");
        }