duanhao1004 2012-11-26 11:43
浏览 118
已采纳

如何加速/分解多个部分的过程。 Rss,Curl,PHP

Im experimenting with some RSS reader/fetcher im writing at the moment. Everything is going smoothly except 1 thing. It's terribly slow.

Let me explain:

  1. I fetch the list of RSS feeds from the database
  2. I iterate every feed from this list, open it with cURL and parse it with SimpleXMLElement
  3. I check descriptions and title's of these feeds with a given keyword, to see if its already in database or not.
  4. If its not i add it to database.

For now i am looping through 11 feeds. Which gives me a page loading time of 18 seconds. This is without updating the database. When there are some new articles found, it goes up to 22 seconds (on localhost).

On a live webserver, my guess is that this will be even slower, and maybe goes beyond the limit php is setup to.

So my question is, what are your suggestions to improve speed.. and if this is not possible, whats the best way to break this down into multiples executions, like say 2 feeds at a time? I'd like to keep it all automated, dont want to click after every 2 feeds.

Hope you guys have some good suggestions for me!

If you want some code example let me know and ill paste some

Thanks!

  • 写回答

2条回答 默认 最新

  • dongliulu1122 2012-11-26 12:20
    关注

    I would suggest you use a cronjob or a daemon that automatically synchronizes the feeds with your database by running a php script. That would remove the delay from the user's perspective. Run it like every hour or whatever suits you.

    Though first, you should possibly try and figure out which parts of the process are actually slow. Without the code it's hard to tell what could be wrong.

    Possible issues could be:

    • The remote servers(which store the feeds) are slow
    • Your local server's internet connection
    • Your server's hardware
    • And obviously the code
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
  • ¥15 onvif+openssl,vs2022编译openssl64
  • ¥15 iOS 自定义输入法-第三方输入法
  • ¥15 很想要一个很好的答案或提示
  • ¥15 扫描项目中发现AndroidOS.Agent、Android/SmsThief.LI!tr
  • ¥15 怀疑手机被监控,请问怎么解决和防止
  • ¥15 Qt下使用tcp获取数据的详细操作