Jump to content

[SOLVED] Long Processing Time


jorgep

Recommended Posts

Hello Fellows,

 

This is kind of complicated problem to explain, I'll do my best to make it clear:

 

The Process:

I have a huge process where I fetch contacts information from a database and from a csv file and then use this contacts data to create a PDF file (I'm using PDFlib). When all the process is done, I set some session variables that include information from the generated file and forces a download through php headers.

 

The Problem:

After I process more than 6000 contacts (around 10 minutes processing) when I force the download it seems that the sessions variables don't get correctly set. I'm almost sure is not a session variable problem (like headers already sent) since it works fine for less than 6000 contacts.

 

My Suspects:

1.- PDFlib dies some how and echo something and I can not set my session variables correctly

2.- Something regarding the memory usage

 

My configuration:

max_execution_time = 3600

max_input_time = 3600

memory_limit = 2048M

 

I need to process around 12000+ contacts if you have a clue of what could be happening that would be great!

 

Thanks for reading and any hint/help/guide would be highly appreciated

Link to comment
https://forums.phpfreaks.com/topic/100687-solved-long-processing-time/
Share on other sites

sessions can be set pre/post any output however the end client can't update the sessions after output.
so
[code]
<?php
session_start();
echo "bob";
$_SESSION['val'] = "bob";
#The session for the user is now blank
?>

<?php

session_start();

$_SESSION['val'] = "Bob";

#session is Bob

echo "bob";

$_SESSION['val'] = "Joe";

#still bob

?>

[/code]

sessions can be set pre/post any output however the end client can't update the sessions after output.
so
[code]
<?php
session_start();
echo "bob";
$_SESSION['val'] = "bob";
#The session for the user is now blank
?>

<?php

session_start();

$_SESSION['val'] = "Bob";

#session is Bob

echo "bob";

$_SESSION['val'] = "Joe";

#still bob

?>

[/code]

 

Excuse me? Where did you hear that rubbish?

 

jorgep: You might want to check your session.cookie_lifetime. It's possible the sessions are timing out.

Thanks for the reply cooldude832 and GingerRobot.

 

cooldude832: I know that, and that is almost dismissed since the script is working perfectly for less than 6000 contacts

 

GingerRobot: That sounds very logic, I just checked it and it is set to 0

; Lifetime in seconds of cookie or, if 0, until browser is restarted.
session.cookie_lifetime = 0

Do you think I should set it to a number or something?

 

It's a pain in the rear to test this script since I have to wait 40+ minutes until I get a result back.

 

Thanks again for your answer

0 should be fine.

 

It might be worth setting PHP to ignore a user abort. I seem to remember some issues with scripts taking a long time to execute relating to this setting, though i can't find anything to confirm that at the moment. If you want to give it a try, add this:

 

ignore_user_abort(TRUE); 

 

To the top of your script.

 

 

I think the idea goes something like that if the browser doesn't recieve any information for a while, it terminates the session. I could be talking rubbish here though - as i say, its just a vague recolection.

;D ;D ;D ;D

 

It worked!! I don't know why it just took 20 minutes to process all 12000+ contacts, man! I've become an optimization guru after this hahaha!

 

At the beginning of the main function i added

ini_set("session.cookie_lifetime",4000);

 

Thanks a lot GingerRobot you rock!

Yup, it worked, I did it again and this time it last 39 minutes and worked fine. What I'm not sure if it was that specific change that made it work, cuz I added some other stuff.

 

Thanks anyway I could say that your suggestion solved it hehe!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.