I am experiencing a very strange issue with Phalcon.
Whenever I use Response
inside a controller the framework becomes very slow. Here is my simple controller:
<?php // file: app/controllers/TestController.php use Phalcon\Mvc\View; class TestController extends ControllerBase { private $response; public function initialize() { $this->view->setRenderLevel(View::LEVEL_NO_RENDER); $this->response = new Phalcon\Http\Response(); $this->response->setStatusCode(200, "OK"); } public function indexAction() { $this->response->setContent("phalcon")->send(); // very slow } }
Whenever I use new Phalcon\Http\Response();
Phalcon becomes very slow. For example testing it with:
ab -c 50 -n 100 ...
Request/sec: 10
If I use a blank Controller I get
Request/sec: 1000+
The route is:
<?php //file: app/config/routes.php $router = new \Phalcon\Mvc\Router(); $router->add("/:controller/:action", array("controller" => "test", "action" => "index"));
I tested it on AWS:
c4.large PHP 5.5.9-1ubuntu4.6 (cli) (built: Feb 13 2015 19:17:11) 2 cpu - 3.75gb ram Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.6
We experienced the same behavior on a Macbook pro with osx 10.10.1
The problem is when I call the send()
method on the response:
$this->response->send(); // slows down everything
Note
As suggested by @Phate01 I tried return $response;
instead of $response->send();
and it is still very slow