Jump to content

Need advice and help to execute a very long php script


skarfr

Recommended Posts

Hello everybody,

 

I am developping a php script who parse a lot of remote rss feeds and save rss's datas on a local mysql database.

Every morning, i have a cron who launch this kind of function:

$listRss = getAllRssURLFromByDB();					//I put on an array all rss urls with an SQL statement from my local database

foreach($listRss as $rssURL) {						//foreach remote rss url
  $dataToPutOnLocalDB = parseRSS($rssURL);			//I launch a parser (curl and co) to get remote datas
  sql_insertDataOnDatabase($dataToPutOnLocalDB);	//and i save datas on my local database
}

 

My problem is that the execution is too long.

 

I have initialise my server with these values:

ini_set('mysqli.reconnect', 'On');
ini_set('max_allowed_packet', '128M');
ini_set('memory_limit', '128M');
ini_set('max_execution_time', '200');

 

But i still have errors like "Maximum execution time exceeded" and "MySQL server has gone away"

At last, i will have hundred of rss url in my database (so it will be longer).

 

To resolve errors, i thought about multi threading (like in C#, java...).

Do you think that launch 1 thread by RSS parsing (i mean the content of the foreach block) will increase performances and resolve errors like "Maximum execution time exceeded" and "MySQL server has gone away"?

 

How to do that in PHP (if you know a good class or a good tuto...)?

 

Do you have other ideas to resolve this kind of problems ?

 

Thank you :)

 

(and sorry for my english...)

 

Peter

 

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.