For Programmers: Free Programming Magazines  


Home > Archive > PHP Programming > March 2004 > Re: a quick hack of an RSS reader - can this destroy a webserver?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: a quick hack of an RSS reader - can this destroy a webserver?
lawrence

2004-03-27, 11:54 pm

I posted before about this, but my amazement continues to grow. I'm at
a university right now with, I assume, multiple high speed lines to
the Internet. I'm working on my website and the connection is super
fast - until I run the following script. Then my site nearly freezes.
Now how is that possible? I'm only being sent maybe 30 k of
information, which should take an eye blink with all bandwidth this
university has. Is it possible this script is so resource hungry it
actually effects the performance of the web server?



lkrubner@geocities.com (lawrence) wrote in message news:<da7e68e8.0403260044.686c8929@posting.google.com>...
> Tonight I wanted to throw together a quick-n-dirty RSS reader, so I
> played around with some stuff and got this script working. I tried, as
> you can see, to work with the XML functions, but was stymied by the
> fact that there are almost a dozen RSS formats, and thinking of a
> universal way to parse all the different formats was beyond what I
> could accomplish tonight. But this thing works, it gets text and puts
> it on the screen and gives me links to click on.
>
> What surprises me and bothers me is that it is stunningly slow.
> Extraordinarily slow. I put this script up on my site and subscribed
> to 1 weblog (Kimberly Swygert's) and it took several minutes for the
> text to show up. Then I subscribed to 5 more weblogs, and now the
> thing takes 10 minutes to render. I leave it open in one window and do
> work in another.
>
> When I comment out everything but the file() line, it is still slow.
> Why should file() be so extremely slow? When I go to these websites
> with my web browser, the sites render quickly enough, and this script
> is executing on a server that should have much faster access to the
> internet than I do. So what is up?
>
>
>
> function elementsAdminShowRssFeeds() {
> $controllerForAll = & getController();
> $selectObject = & $controllerForAll->getObject("McSelect", " in
> elementsAdminShowRssFeeds().");
> $resultsObject = & $controllerForAll->getObject("McResults", " in
> elementsAdminShowRssFeeds().");
>
> $selectObject->begin("In elementsAdminShowRssFeeds(), we are going
> GetAllOfType to try to get a list of all RSS feeds.");
> $selectObject->setDatastoreObject();
> $selectObject->setQueryObject("GetAllOfType");
> $selectObject->setInfoToBeSought("rssFeeds");
> $selectObject->getInfo();
>
> $howMany = $selectObject->getCountOfReturn();
>
> if ($howMany > 0) {
> for ($i=0; $i < $howMany; $i++) {
> if ($i > 0) echo "\n\n\n<br><br><br><hr>\n\n\n<br><br><br>";
> $row = $selectObject->getRowAsArrayWithStringIndex();
> $address = $row["cbLinksToWhatUrl"];
> echo "We will now try to get this address: $address. Please be
> patient, this takes awhile.<hr>";
> flush();
> $data = implode("", file($address));
> $data = str_replace("<p>", "\n\n", $data);
> $data = strip_tags($data);
> $text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a
> href=\"\\0\">\\0</a>", $data);
> $text = nl2br($text);
> $text = str_replace("<br />\n<br />\n<br />\n<br />\n", "<br />\n",
> $text);
> $text = str_replace("<br />\n<br />\n<br />\n<br />\n<br />\n<br
> />\n<br />\n<br />\n", "<br />\n", $text);
> echo $text;
> // if ($data != "") {
> // $parser = xml_parser_create();
> // xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
> // xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
> // xml_parse_into_struct($parser, $data, $values, $tags);
> // xml_parser_free($parser);
> // }
> }
> }
> }

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com