swoole http server 整合 phalcon,ab测试,报php内存耗尽
phalcon
php
swoole
在整合swoole http server和phalcon,server.php如下:
<code><?php use Phalcon\DI; use Phalcon\Loader; use Phalcon\Mvc\Router; use Phalcon\Mvc\Dispatcher; use Phalcon\Http\Response; use Phalcon\Http\Request; use Phalcon\Mvc\View; use Phalcon\Db\Adapter\Pdo\Mysql as Database; use Phalcon\Mvc\Application as BaseApplication; use Phalcon\Mvc\Model\Metadata\Memory as MemoryMetaData; use Phalcon\Mvc\Model\Manager as ModelsManager; class Application extends BaseApplication { protected function registerAutoloaders() { $loader = new Loader(); $loader->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(); }); //Registering 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(); }); # 启动服务器 $http->start();</code>
登录后复制
浏览器访问没什么问题
做ab测试就报错了
<code>ab -n 10000 -c 1000 -rk http://phalcon.com/</code>
登录后复制
错误信息:
<code>[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</code>
登录后复制
请教这是什么原因导致的,是onRequest那里写的不对吗?
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章
R.E.P.O.能量晶体解释及其做什么(黄色晶体)
2 周前
By 尊渡假赌尊渡假赌尊渡假赌
击败分裂小说需要多长时间?
1 个月前
By DDD
R.E.P.O.最佳图形设置
2 周前
By 尊渡假赌尊渡假赌尊渡假赌
刺客信条阴影:贝壳谜语解决方案
1 周前
By DDD
R.E.P.O.如果您听不到任何人,如何修复音频
3 周前
By 尊渡假赌尊渡假赌尊渡假赌

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

PHP 8.4 带来了多项新功能、安全性改进和性能改进,同时弃用和删除了大量功能。 本指南介绍了如何在 Ubuntu、Debian 或其衍生版本上安装 PHP 8.4 或升级到 PHP 8.4

CakePHP 是 PHP 的开源框架。它的目的是使应用程序的开发、部署和维护变得更加容易。 CakePHP 基于类似 MVC 的架构,功能强大且易于掌握。模型、视图和控制器 gu
