Help me! The CPU resource consumption is to high!

The environment:

Server 2008

IIS 7.0

PHP 5.2

Yii 1.0.4

This is my test function

[size="7"]1024

Controller.png

Just return a string "Success!"

1025

View.png

Start 100 thread test the CPU is to 100%

1026

CPU_ISS_CGI_1.png

1027

CPU_ISS_CGI_2.png

Anybody know the reason?


A simple statement in Yii make apache consume CPU 100%

Test Environment:

1031

OS.png

CPU:Q9400(2.66 4Core)

OS: Windows server 2008(64)

PHP:5.2.14

Web Server:Apache2.0

No APC, YII:

Cache off, debug off, log off,

Test Method:

page a : testa.php,




<?php 

	for ($index = 0; $index < 10; $index++) {

		echo $index;

	}

	echo "<br/>";

	for ($index = 0; $index < 30; $index++) {

		echo $index." ";

	}

	echo "<br/>";

	for ($index = 0; $index < 50; $index++) {

		echo $index." ";

	}

	echo "<br/>";

	echo time();

 ?>



page b : testb.php, a simple page return data from database by PDO without yii




<?php 

	function createPDOConnect()

    {	

		$connection;

		try{

			$connection = new PDO("oci:dbname=192.168.1.13/ORCL;charset=AL32UTF8", 'WDM_APP', '1234');

			$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );

			$connection->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);

			$connection->setAttribute(PDO::ATTR_TIMEOUT,60*60*10);

		}catch(PDOException $e){

			echo ("Error:".$e->getMessage()."<br>");

			die();

		}

        return $connection;

    }

	

	$dbh = createPDOConnect();

	$sql = "SELECT * FROM WEBSITE t WHERE ROWNUM<=10";

	

	$stmt = $dbh->prepare( $sql );

	$stmt->execute();

	$selectDataArray = $stmt->fetchAll(PDO::FETCH_ASSOC);

	echo count($selectDataArray);

	foreach($selectDataArray as $d){

		echo $d['WEBSITE_ID'];

	}


 ?>



page c : testc.php, a simple page return "Hello world" with yii

SiteController.php




public function actionIndex()

	{

		$this->render('index');

	}



index.php




<?php 

	$this->layout=false;

	echo "Hello World!;

?>




page d : testd.html a simple html page without yii




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Detail</title>

<link rel="stylesheet" type="text/css" href="/wm/css/info_en_us.css" />

</head>

<body>

1234567890

1234567890

1234567890

</body>

</html>



Client Thread Count: 100

Test Result:

test on page a, apache cpu 5%

test on page b, apache cpu 35%

test on page c, apache cpu 95%

test on page d, apache cpu 3%

I also test it on apache 2.2, the same result!

Why does YII consume so much CPU via apache?

why did you give a try to using lamp or wamp stack instead IIS?. for your issue restart the system and check again

I used the Apache 2.2.17 the cpu also 100%!

1028

Apache_1.png

1029

Apache_2.png

As you can see in the processes list the ORACLE database is consuming your CPU >60%

use apache 2.0

1030

Apache_2.0.png

hello, :unsure:

my suggestion is to try Zwamp (a light weight hosting server) and possibly learn to use APC or eAccelerator to bust speed