The processor uses 100% resource, and therefore the queue is not completed

My code is as follows.

for($i = 0; $i <= 100; $i++) { $objUser = [ "UserName" => $request["UserName"] . $i, "EmailAddress" => $request["EmailAddress"] . $i, "RoleID" => RoleEnum::ProjectManager, "Password" => $request["Password"], ]; $RegisterResponse = $this->Register->Register($objUser); $Data = $RegisterResponse["Data"]; $job = (new AccountActivationJob($Data)); dispatch($job); } 

100 users are created above the code, and every time a queue is created for sending notifications by e-mail. I use the default queue for the database.

I have a GoDaddy hosting account. For some reason, CPU usage reaches 100. Here is a screenshot.

enter image description here

Finally, the cycle stops between them. Below is a screenshot after 5 minutes.

enter image description here

Here is my problem: it cannot continue to create 100 users. I do this to test the implementation of the fetch queue when multiple users submit a registration request. Am I doing something wrong?

+5
source share
3 answers

I drew conclusions and found that I should switch to VPS instead of Shared hosting. here are the good and cheap GoDaddy plans. https://in.godaddy.com/hosting/vps-hosting

enter image description here

0
source

As stated above, GoDaddy has many resource limits. You can send only 100 letters per hour - this is what I heard.

This is also not at a time. If it detects that you are sending a lot of emails, your process is blocked.

Instead, you can queue messages sent 1 in 20 seconds or 30 seconds. This will help to limit resources, and your letters will be sent to customers without any problems.

You can use the sleep function for this.

+5
source

Godaddy has a limit of resources that you can use. If you go to it, it will kill processes in ssh.

Limits are available here.

Try starting a php process with another good parameter.

What do I do when I need to use the artisan command, which uses a lot of resources.

0
source

Source: https://habr.com/ru/post/1265925/


All Articles