简体   繁体   English

大型php脚本会减慢其余应用程序的速度...为什么?

[英]large php script slowing down the rest of application… why?

I have a large php web scraping script that logs the results onto a mysql database as it goes.The script generally runs for 5 to 10 minutes at a time. 我有一个大型的php web抓取脚本,它将结果记录到mysql数据库中,该脚本通常一次运行5至10分钟。

The problem is that when this script is running other pages on the application will not load. 问题在于,当该脚本运行时,应用程序上的其他页面将无法加载。

The script is on a dedicated server with plenty of RAM so I have tried increasing the allowed memory usage for MYSQL and PHP. 该脚本位于具有大量RAM的专用服务器上,因此我尝试增加MYSQL和PHP的允许内存使用量。 Also increased the max allowed connections. 也增加了允许的最大连接数。 None of this has helped. 这些都没有帮助。

Does anyone have any ideas about what else I can try? 有人对我可以尝试的方法有任何想法吗?

Probably, problem in your session. 可能是您会话中的问题。 Try to use session_write_close() before you start "big script". 在启动“大脚本”之前,请尝试使用session_write_close()。

well, there's a big difference between "slowing down" and "not load"! 好吧,“减速”和“不加载”之间有很大的区别!

try the following: 尝试以下方法:

  1. build a static html site and check if it is loaded well during the execution of the big script 构建一个静态html网站,并在执行大脚本期间检查它是否加载正确
  2. build a php site that doesn't connect to the DB (just echo something) during the execution of the big script 建立一个在执行大脚本期间不连接到数据库(仅回显某些内容)的php站点
  3. build a small php site that connects to the DB (just select something from a table) 建立一个连接到数据库的小型php网站(只需从表中选择内容)

if 1 or 2 doesn't work well, your problem has something todo with the web server or server resources. 如果1或2不能很好地工作,则您的问题与Web服务器或服务器资源有关。 if 3 doesn't work well, there could be resource issues with the mysql server. 如果3工作不正常,则mysql服务器可能存在资源问题。

if everything works well, check the scraping script. 如果一切正常,请检查抓取脚本。 does it lock any table that is needed by the main application? 它会锁定主应用程序所需的任何表吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM