PHP Timeout - Error 500

  • Calum
  • Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
7 years 8 months ago #102166 by Calum
PHP Timeout - Error 500 was created by Calum
I've been having some issues with PHP timing out on me when a user has paid (CardSave) and is taken to a Verified By Visa page then comes back and should see the payment confirmation page.

Its taken a bit of hunting down the issue - but increasing the PHP timeout seems to have reduced it from 9 times out of 10 it giving the user a 500 error, and now about 1 out of 10, and I've increased the time out some more.

I do have EB sending the invoice attached to the email (it times out before that's sent), and one or two plugins like adding a user to ACYMailing.

I assume it might be the create PDF function that times out - its always seemed a slow process. Asking to resend an email in the backend seemed to get 500 errors too.

So I'd like to make a couple of suggestions -

Ideally when the user is returned to the site and the PDF generation is taking place I think it would be better to show a progress indicator of some sorts. Second if that actually went via two pages that might reduce some time outs (but if PDF on its own is the issue it wont)

Secondly - does the pdf email actually need to be produced on the fly like that? Or could it be handled via a mail queue. With a cronjob trigger? The timeouts would happen for the cronjob. End user wouldn't get email (you can see no email in the log and the queue would still show it unsent) - but they wouldn't get a timeout - think the payment failed and try again...

Please Log in or Create an account to join the conversation.

  • Calum
  • Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
7 years 8 months ago #102167 by Calum
Replied by Calum on topic PHP Timeout - Error 500
For me, for just now the solution has been some php.ini settings:

max_execution_time = 60000 ; Maximum execution time of each script, in seconds
max_input_time = 60000 ; Maximum amount of time each script may spend parsing request data

According to the PHP documentation the time out is set in seconds. We tried increasing to 6000 - which is 100 minutes and still got timeouts! We increased to 10,000 and got 90% success - but in theory that's over 2 hours - its not taking anything like that. I've now increased to 60,000 - so 16hours.

I have a suspicion that either PHP its self has this wrong or a PHP module does and has this in milliseconds or something. That would mean we were getting time outs at 6 seconds 90% of the time, 10 seconds 90% of the time, and I'm not expecting any in 60 seconds...

There may be a way to use set_time_limit() before each sub-call to extend the time out as well, as I believe it resets the timeout start! There is probably some better way to handle it timing out too? i.e. instead of a 500 error could it simply skip the PDF section and send an email to admin address saying "confirmation not sent due to time out" and show the end user a success output..

Please Log in or Create an account to join the conversation.

More
7 years 8 months ago #102185 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic PHP Timeout - Error 500
I would say that it is a strange thing. Generate PDF invoice should not take much time like that. Maybe it causes by something else

Maybe you can try to download an invoice from backend to see whether it is taking long time or shot? Maybe the slow causes by the sending email process itself

Tuan

Please Log in or Create an account to join the conversation.

  • Calum
  • Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
7 years 8 months ago #102270 by Calum
Replied by Calum on topic PHP Timeout - Error 500
It takes 8.7 seconds from clicking the invoice in the backend to it beginning to be opened in the browser. I'm confident 8.5seconds of that is creating the file!

I can send emails from J! and from EB etc without noticeable delays only when the PDF invoice is involved...

Please Log in or Create an account to join the conversation.

More
7 years 8 months ago #102275 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic PHP Timeout - Error 500
That's really strange issue, thought. No-one had that slow and I don't have any clue about this issue. Do you have a really complicated invoice layout? We are using TCPDF library for generating invoice and it has been working well for other customers for year

Maybe you can try to restore to use the default invoice layout in the extension to see whether it still slow like that? We need to figure out why it happens

Tuan

Please Log in or Create an account to join the conversation.

  • Calum
  • Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
7 years 8 months ago #102311 by Calum
Replied by Calum on topic PHP Timeout - Error 500
Reduced image size. Now getting a PDF that is <25kb vs 500kb. Production time is <2secodns probably quicker.
Off to check Member Pro now too!

Please Log in or Create an account to join the conversation.

More
7 years 8 months ago #102326 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic PHP Timeout - Error 500
OK. Thanks for the info. Please let us know if you need us check anything else

Regards,

Tuan

Please Log in or Create an account to join the conversation.

Moderators: Tuan Pham Ngoc