Swoolehttpserver integrated with phalcon and AB tests, reporting php memory depletion

Source: Internet
Author: User
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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.