views:

46

answers:

3

Hi,

I've deployed a project in the staging server and experienced issues regarding the Zend_Rest. I created a simple test service that should return "hello world" on the calling script. The call would take approx. 4secs to finish. It is really slow given the simple task. Any suggestions for optimization?

here's some code snippets :

// $url is a connetion to a resful controller

$client = new Zend_Rest_Client($url); $response = $client->printHelloWorld()->post(); echo $response->printHelloWorld->response;

Server controller has :

public function getAction()
{
    $server = new Zend_Rest_Server();
    $server->setClass('Webservice_User');
    $server->handle();
}
A: 
  1. Install APC or any other PHP accelerator, Zend is really heavy
  2. Bench server controller separately (ab -c 10 -t 10 http://sdfklsdf) to isolate issue on server/client.
BarsMonster
A: 

at your server :

  1. don't write server at controller. write it at index.php / other file
  2. use just a simple bootstrap
  3. don't include any unimportant zend library class

ex (index.php) :

set_include_path(
    implode(PATH_SEPARATOR, array(
        realpath(APPLICATION_PATH . '/../library'),
        get_include_path(),
)));

require_once 'Zend/Application.php';

$application = new Zend_Application(
     APPLICATION_ENV,
     APPLICATION_PATH . '/configs/application.ini'    
);

$application->bootstrap();    

$server = new Zend_Rest_Server();
$server->setClass('Webservice_User');
$server->handle();
Swing Magic
A: 

Hi Guys,

After much research, I guess I will not be using zend rest for the application. Zend_Rest examples around the web has an RPC implementation which is really heavy because of the reflection process. I was able to drop it more but decided that webservice is not the right way for the special process that I am doing.

Hanseh