Integrate swoolehttpserver and phalcon, server. php is as follows: {code ...} if there is no problem with browser access, an error will be reported when AB testing. {code ...} error message: {code ...} why is this caused? is it wrong with onRequest? In the integration of swoole http server and phalcon, server. php is as follows:
RegisterDirs (array ('.. /apps/controllers /','.. /apps/models/'); $ loader-> register ();}/*** This methods registers the services to be used by the application */protected function registerServices () {$ di = new DI (); // Registering a router $ di-> set ('router ', function () {return new router ();}); // Registering a dispatcher $ di-> set ('dispatcher ', function () {return new dispatcher () ;}); // Registeri Ng a Http \ Response $ di-> set ('response', function () {return new response ();}); // Registering a Http \ Request $ di-> set ('request', function () {return new request ();}); // Registering the view component $ di-> set ('View', function () {$ view = new view (); $ View-> setViewsDir ('.. /apps/views/'); return $ view;}); $ di-> set ('DB', function () {return new Database (array ("host" => "localhost", "username" => "root "," Password "=>" "," dbname "=>" invo "));}); // Registering the Models-Metadata $ di-> set ('modelsmetadata', function () {return new MemoryMetaData ();}); // Registering the Models Manager $ di-> set ('modelsmanager', function () {return new modelsManager () ;}); $ this-> setDI ($ di );} public function main () {$ this-> registerServices (); $ this-> registerAutoloaders () ;}$ application = null; $ http = new swoole _ Http_server ("0.0.0.0", 9501); $ http-> on ('request', function ($ request, $ response) {try {$ _ GET =$ _ POST =$ _ COOKIE =$ _ REQUEST = []; if (! Empty ($ request-> get) {$ _ GET = $ request-> get; $ _ REQUEST + =$ _ GET;} if (! Empty ($ request-> post) {$ _ POST = $ request-> post; $ _ REQUEST + =$ _ POST;} if (! Empty ($ request-> cookie) {$ _ COOKIE = $ request-> cookie;} global $ application; $ html = $ application-> handle ($ request-> server ['request _ uri '])-> getContent (); $ response-> end ($ html );} catch (\ Exception $ e) {print_r ($ e); echo $ e-> getMessage () ;}}); $ http-> on ('workerstart ', function ($ server, $ workerId) {global $ application; $ application = new Application (); $ application-> main ();}); # start the server $ http-> start ();
No problem with browser access
An error is reported when you perform an AB test.
ab -n 10000 -c 1000 -rk http://phalcon.com/
Error message:
[root@localhost public]# [2016-08-25 17:12:45 *12502.0] ERROR zm_deactivate_swoole (ERROR 103): Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 16384 bytes) in /srv/www/single/public/server.php on line 126.[2016-08-25 17:12:45 $12497.0] WARNING swManager_check_exit_status: worker#0 abnormal exit, status=255, signal=0
Why is this caused? is it wrong with onRequest?