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
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]

Link to comment
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]

 

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

;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!

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.