1

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.

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. Also increased the max allowed connections. None of this has helped.

Does anyone have any ideas about what else I can try?

8
  • 1
    Is your network connection saturated? Is your CPU maxed out? Commented Nov 1, 2014 at 18:55
  • 1
    Does the script use the same tables as the rest of the app? Commented Nov 1, 2014 at 18:56
  • InnoDB or MyISAM engine on your DB? Row level locks v.s. table level locks. huge difference. Commented Nov 1, 2014 at 18:57
  • - I'm not sure if my CPU is maxed out, how would I go about finding this out? Commented Nov 1, 2014 at 18:58
  • run top from the command line. Commented Nov 1, 2014 at 18:59

2 Answers 2

2

Probably, problem in your session. Try to use session_write_close() before you start "big script".

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks @maxim, this is a really useful thing to understand - it was relevant for me when running multiple php scripts from ajax calls. They were queuing up, now they're running concurrently.
0

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
  2. build a php site that doesn't connect to the DB (just echo something) during the execution of the big script
  3. build a small php site that connects to the DB (just select something from a table)

if 1 or 2 doesn't work well, your problem has something todo with the web server or server resources. if 3 doesn't work well, there could be resource issues with the mysql server.

if everything works well, check the scraping script. does it lock any table that is needed by the main application?

1 Comment

Your last question was answered in the comments, as the Engine is InnoDB, this means the engine only performs row level locks, as opposed to table level locks that occur in MyISAM.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.