swoolehttpserver整合phalcon,ab测试,报php内存耗尽
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了swoolehttpserver整合phalcon,ab测试,报php内存耗尽,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2385字,纯文字阅读大概需要4分钟。
内容图文
在整合swoole http server和phalcon,server.php如下: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();
浏览器访问没什么问题
做ab测试就报错了
ab -n 10000 -c 1000 -rk http://phalcon.com/
错误信息:
[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
请教这是什么原因导致的,是onRequest那里写的不对吗?
内容总结
以上是互联网集市为您收集整理的swoolehttpserver整合phalcon,ab测试,报php内存耗尽全部内容,希望文章能够帮你解决swoolehttpserver整合phalcon,ab测试,报php内存耗尽所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。