为什么PHP脚本在新服务器上的执行时间长?

I have a server that has 2 quad core processors (2.4 GHz, 16GB RAM). I have a some PHP scripts that run under very heavy load. Most of these scripts do few things:

  1. Fetch Data from database (just a single row, from a small table)
  2. Fetch Data from other server (mainly Facebook)
  3. Upload a small photo
  4. Update Database table (this table is very heavily used, and number of rows grows very quickly, almost 2 rows per second)

The problem is that, the scripts are taking too much time to execute. I had a server previously which has lower configuration (one quad core processor, 6GB RAM), but scripts took 4-5 sec to complete. But now, execution time is 30-40sec, even more.

HOW I MEASURE EXECUTION TIME? I measure microtime() at start of script and end of script and subtract them. I just needed a rough estimate.

SERVER CONFIGURATION: Here are some parameters set in apache config:

server_limit = 350
max_chlid = 350
keep_alive = off

Other Characteristics: 1. When server is not under heavy load, execution time is very small 2. Previous server took very less time to execute, even under heavy load

I don't know what else details should I include. Please ask me, and I will post them here.

What should I do to improve this?

Update:

I have figured out the problem is with ImageMagick library. I googled and tried few soution like disabling OpenMP. But it hasn't helped much

This could have many reasons:

  1. Are your queries "slow"?
  2. Is the server configuration right?
  3. Has it a slow bandwidth?
  4. Is MySql-Server configuration right?
  5. What is the format of the table you insert?
  6. Is something else (a cronjob e.g.) killing the database?

I would post this as a comment, but unfortunatly i can't please clear up those questions and tell what you find out ;)

I'm suggesting to do profiling with xdebug and then analyze it with software like kcachegrind. Then you will know what's taking time.

I would start to decouple the problem. Test each action (fetch from db, fetch from fb, upload, etc.) separately.

At the same time check if all the components of your new server env are the same (packages, version, config, etc.) as before.