Jump to content

Recommended Posts

I have created a website, which runs a small php script using curl every 5 minutes.

These are the steps the script uses:

 

1. Access list of RSS feeds from DB

loop {

2. Download RSS Feed

loop {

3. Does RSS entry exist in the database ?

Yes - Next Entry

No - Add to Database

}

}

 

My problem is, is that there are a number of entries.

I run a script every minute, which divides the list into 5 categories.

Ie: I run

 

10:00 - RSS Feeds 1-15

10:01 - Rss Feeds 16 - 30

10:02 - Rss Feeds 31 - ... etc etc etc

 

Things is, the script is eating up the systems load, and causing it to peak as high as 40 or 50.

 

Is there anyway to optimize this, so that it reduces the server load??

An idea I originally had was to use the generated time on the rss feeds, problem is, cause some of them are generated on the fly, it wont work.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/175340-php-optimization-help/
Share on other sites

I have a program that does exactly the same thing and the server isn't heavily loaded. Steps to take:

 

1. Optimise your queries. Make sure that you have indexes on the correct fields when you are checking for duplicates.

2. Unset variables after use, i.e once you load the feed into a variable, after you have inserted into database, unset it.

3. Add more memory to the server and allocate to the script. This is the simplest option.

4. Record a date-time on the feed so that the script will not try and get news from this feed if it has already in lets say the last 24hs. This is a simple query.

 

My script obtains news from thousands of feeds and can take hours to complete however I would suggest you run this on a linux box with only the required software installed. I would say that a windows box is a bad choice as a lot of memory is already allocated to the operating system.

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.