If you are to loop through these arrays which method would you choose

exactly my fears,
if 10,000 finishes in 4.8minutes

100,000 will likely be 48minutes.

I think I have hit the rock, will call users to come and uproot their emails from our server oh.

If you are in my shoes how will you approach this problem?

What needs to be knocked off, and what should be added or which approach should be adopted for a smooth run?

I would find a way not to have to bulk process 300,000 things all at once. Why are you needing to do that? What is causing 300,000 simultaneous events?

subscriptions and notifications alert.

All subscribers needs it send to them.

SELECT GROUP_CONCAT('email') FROM users GROUP BY (id/1000)
Returns 300 records.
send_email($groupemail)

There’s no reason to send 300,000 individual emails for a bulk mail that contains no personal information. Send 300. Or 3000. Something other than 300,000. Whatever the limit on my mass-mailing service’s BCC list is.

I have this silly idea i don’t know if it solves the problem, thats depending how a script execution is counted

We have 100,000
So use break it into 1000 per units and thats 100
Then instead of processing it in a single page
let’s say process.php

i will make a posted or get request call to
process.php?iteration=1
process.php?iteration=2
process.php?iteration=3

Which makes each script to finish in 29secs

And we only have 100 calls made to the script

But the question is, does process.php? iteration=1 still counts as process.php?iteration=2 in execution time?

But there emails are unique per user, also we personalized our emails by firstname and other details as in the users meta

So my advice would be… dont. :smiley:

I would do this in a cron job on the background, so you have infinite execution time. Trying to work around PHPs max execution time usually only results in overly complex and unreadable code.

Also, when sending this many emails, make sure to read up on limits from email providers. For example, gmail may not accept any more than say 100 (example) emails a minute from your server.

There is a reason people use services like MailChimp and the like to do mail delivery. It’s just so very complicated once you get to sending loads of emails. Even though it sounds like it should be easy.

1 Like

Thanks alot but MailChimp or other mail sending service are off the picture.

I just need to understand the full meaning of max execution time and where it applies.
I may have other huge loops in the future that does not require email sending.

So is imperative that I graps the full understanding of this execution limit.

test.php : is an execution counted as a php script which means all functions running in it from top to bottom?

Inbuit Function () : does it mean operations or functions performed or performing under this a given function from start to finish within the curl closures?

If page like test.php is a determining factor, then does query’s or multiple visits separate it as a bundled execution time?

I just need clarification please.

The execution time is the time between the HTTP request hitting PHP and PHP replying with an answer. The maximum execution time is simply the maximum time allowed for this.

So, I click a link, and then the PHP script has 30 seconds to come up with an answer. If it can’t, meaning the script is still busy after 30 seconds, PHP will force the script to stop and return an error. Whatever the script does in these 30 seconds (sending mail, querying a database, etc, etc) is completely irrelevant.

Do note that 30 seconds is the default setting for PHP and can be increased. However, other servers in the way, such as NGiNX, apache, a load balancer, etc, may have their own timeout. The maximum execution time over all servers is the determined by the server with the lowest execution time. So if NGiNX has a timeout of 10 seconds, you can set PHP to a limit of an hour, but the request will still be cancelled after 10 seconds.

2 Likes

This is detailed and expository.
Thanks alot