Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I wasn't sure whether to post this here or on stackoverflow, so apologies if its in the wrong place.

I have about 7 php scripts running on a centOS VPS. Each of these scripts contacts a game server and processes the logs, with the logs it either does some database queries or sends info back to the game server.

I am having an issue where some of the scripts will randomly become REALLY slow to respond and I don't know where to start with my debugging. Each script connects to its own database schema but on the same MySQL server. Each script will do about 4 inserts per second and twice as many select statements on their respective databases. I thought a database lockup may cause the issue but some console messages that are read from the database are sent to the game servers console without issue every 30 seconds, even when the script is slow to responding to other commands.

Non of the scripts are using a lot of memory or CPU power. About 0.1% each.

I know this information is really vague but I don't know linux very well at all (in fact, top is about my limit) and I really don't know where to start debugging this.

Thanks.

share|improve this question
1  
My first start would be MySQL's Slow Query Log serverfault.com/questions/241113/… –  DerfK Mar 14 '11 at 22:39
    
Also check for possible incorrect use of transactions, such as not committing them, which can result in delays before they timeout. –  John Gardeniers Mar 14 '11 at 23:56
    
@Derk: Added the option in now. Went to restart MySQL and now it won't start - Going well so Far. @John: I am not using any transactions that I know of. I'm certainly not starting any myself. –  webnoob Mar 14 '11 at 23:58

1 Answer 1

up vote 1 down vote accepted

A few things you can try:

  • Check the system and application logs for any relevant messages. Sometimes there are issues/timeouts that will get logged there. This includes the MySQL slow query log that DerfK mentioned.
  • Some sort of monitoring system on the server would be nice to have. This would tell you for sure if there are any obvious bottlenecks (CPU, Memory, IO, etc...). Alternatively, if the issues happen at specific times you can use the various command line tools top, vmstat, iostat, etc... to check the system status. Make sure you eliminate the obvious/common causes first (high CPU, low RAM, swap usage, IO locks/issues/high load).
  • If you can benchmark/stress test your scripts it might help determine the source of the issue. Being able to reliably duplicate an issue is a big step in solving it.
  • Consider adding some basic logging in your scripts. I would start by doing a basic check of the script running time and output something only if it took more than X seconds to run.
  • You mention the scripts parse logs. If possible try running the scripts over the same set of logs multiple times and see if the issue happens at the same place or randomly at different places. You can also trying disabling writes to see if the issues are caused by the reads/parses or the writes (or both).
  • If you find particular queries that are running slow try running/testing them manually on the database via the command line client. This will tell you if the queries themselves are slow or just the execution of them remotely from PHP for some reason.
share|improve this answer
    
This was some good advice. I haven't found the issue specifically but I have found something that "may" be causing it. THanks. –  webnoob Mar 15 '11 at 23:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.