電子發(fā)燒友App

硬聲App

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評(píng)論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會(huì)員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示
創(chuàng)作
電子發(fā)燒友網(wǎng)>電子資料下載>電子資料>mongols C++服務(wù)器基礎(chǔ)設(shè)施

mongols C++服務(wù)器基礎(chǔ)設(shè)施

2022-06-23 | zip | 4.73 MB | 次下載 | 免費(fèi)

資料介紹

授權(quán)協(xié)議 MPL-2.0
開發(fā)語言 C/C++
軟件類型 開源軟件
所屬分類 程序開發(fā)、 高性能網(wǎng)絡(luò)開發(fā)庫

軟件簡(jiǎn)介

mongols?是一個(gè) C++ 庫。

依賴:

  • linux

  • pcre-devel

  • hiredis-devel

  • zlib-devel

  • openssl-devel

  • curl-devel

sudo?yum?install?pcre-devel?zlib-devel?openssl-devel?hiredis-devel?libcurl-devel

或者:

sudo?apt-get?install?libpcre3-dev?zlib1g-dev?libssl-dev?libhiredis-dev?libcurl4-openssl-dev

特性:

epoll or epoll + multi-threading

  • tcp sever

  • http server

  • websocket server

  • web server

  • leveldb server

  • lua server

  • sqlite server

  • utils

安裝:

make clean && make -j2 && sudo make install && sudo ldconfig

使用:

pkg-config --libs --cflags mongols

例子:

#include#include#include#include#include#include#include#include/*
//websocket?server
int?main(int,char**){
int?port=9090;
const?char*?;
mongols::ws_server?server(host,port,5000,2048,4);

auto?f=[](const?std::string&?input
????????????,?bool&?keepalive
????????????,?bool&?send_to_other
????????????,?mongols::tcp_server::client_t&?client
????????????,?mongols::tcp_server::filter_handler_function&?send_to_other_filter){
keepalive?=?KEEPALIVE_CONNECTION;
send_to_other=true;
if(){
keepalive?=?CLOSE_CONNECTION;
send_to_other?=?false;
}
};
server.run(f);
//server.run();
}
*/


/*
//tcp?server?or?tcp?multi-threading?server
int?main(int,char**)
{
auto?f=[](const?std::string&?input
?,?bool?&?keepalive
????????????????,?bool&?send_to_other
????????????????,?mongols::tcp_server::client_t&?client
????????????????,?mongols::tcp_server::filter_handler_function&?send_to_other_filter){
keepalive=?KEEPALIVE_CONNECTION;
send_to_other=true;
return?input;
};
int?port=9090;
const?char*?;

//mongols::tcp_threading_server
mongols::tcp_server

server(host,port);
server.run(f);

}
*/




//http?server?or?multi-threading?server
int?main(int,char**)
{
auto?f=[](const?mongols::request&){
return?true;
};
auto?g=[](const?mongols::request&?req,mongols::response&?res){
//std::unordered_map::const_iterator?i;
//if((i=req.session.find("test"))!=req.session.end()){
//long?test=std::stol(i->second)+1;
//res.content=std::to_string(test);
//res.session["test"]=res.content;
//}else{
//res.content=std::to_string(0);;
//res.session["test"]=res.content;
//}
res.content=std::move("hello,world");
res.status=200;
};
int?port=9090;
const?char*?;
mongols::http_server?
//server(host,port,5000,1024,4);
server(host,port);
server.set_enable_session(false);
server.set_enable_cache(false);
server.run(f,g);
}

/*
//web?server?or?multi-threading?server
int?main(int,char**)
{
auto?f=[](const?mongols::request&){
if(req.&&req.uri.find("..")==std::string::npos){
return?true;
}
return?false;
};
int?port=9090;
const?char*?;
mongols::web_server?
//server(host,port,5000,1024,4);
server(host,port);
server.set_root_path("html");
server.set_mime_type_file("mime.conf");
server.set_list_directory(true);
server.run(f);
}
*/

/*
//leveldb_server?or?multi-threading?server
int?main(int,char**){
int?port=9090;
const?char*?;
mongols::leveldb_server?
//server(host,port,5000,1024,4);
server(host,port);
server.run("html/leveldb");
}
*/

壓力測(cè)試:

[centos@localhost?demo]$?uname?-a
Linux?localhost?3.10.0-862.9.1.el7.x86_64?#1?SMP?Mon?Jul?16?16:29:36?UTC?2018?x86_64?x86_64?x86_64?GNU/Linux
[centos@localhost?demo]$?cat?/proc/cpuinfo|?grep?"processor"|?wc?-l
4
[centos@localhost?demo]$?cat?/proc/cpuinfo|?grep?"cpu?cores"|?uniq
cpu?cores:?2
[centos@localhost?demo]$?cat?/proc/cpuinfo|?grep?"physical?id"|?sort|?uniq|?wc?-l
1

ab -c1000 -n100000 http://127.0.0.1:9090/

Server?Software:????????mongols/0.9.0
Server?Hostname:????????127.0.0.1
Server?Port:????????????9090

Document?Path:??????????/
Document?Length:????????13?bytes

Concurrency?Level:??????1000
Time?taken?for?tests:???8.180?seconds
Complete?requests:??????100000
Failed?requests:????????0
Write?errors:???????????0
Keep-Alive?requests:????0
Total?transferred:??????13300000?bytes
HTML?transferred:???????1300000?bytes
Requests?per?second:????12225.00?[#/sec]?(mean)
Time?per?request:???????81.800?[ms]?(mean)
Time?per?request:???????0.082?[ms]?(mean,?across?all?concurrent?requests)
Transfer?rate:??????????1587.82?[Kbytes/sec]?received

Connection?Times?(ms)
??????????????min??mean[+/-sd]?median???max
Connect:????????0???66?263.3??????7????3020
Processing:?????2???11??11.9??????9?????831
Waiting:????????0????8??11.5??????7?????829
Total:??????????6???77?265.8?????16????3033

Percentage?of?the?requests?served?within?a?certain?time?(ms)
??50%?????16
??66%?????20
??75%?????22
??80%?????23
??90%?????29
??95%???1017
??98%???1025
??99%???1030
?100%???3033?(longest?request)

ab -kc1000 -n100000 -H'Connection: keep-alive' http://127.0.0.1:9090/

Server?Software:????????mongols/0.9.0
Server?Hostname:????????127.0.0.1
Server?Port:????????????9090

Document?Path:??????????/
Document?Length:????????13?bytes

Concurrency?Level:??????1000
Time?taken?for?tests:???1.935?seconds
Complete?requests:??????100000
Failed?requests:????????0
Write?errors:???????????0
Keep-Alive?requests:????100000
Total?transferred:??????13800000?bytes
HTML?transferred:???????1300000?bytes
Requests?per?second:????51671.74?[#/sec]?(mean)
Time?per?request:???????19.353?[ms]?(mean)
Time?per?request:???????0.019?[ms]?(mean,?across?all?concurrent?requests)
Transfer?rate:??????????6963.57?[Kbytes/sec]?received

Connection?Times?(ms)
??????????????min??mean[+/-sd]?median???max
Connect:????????0????0???3.2??????0??????48
Processing:?????8???19???1.4?????18??????48
Waiting:????????0???19???1.4?????18??????25
Total:??????????8???19???3.1?????18??????64

Percentage?of?the?requests?served?within?a?certain?time?(ms)
??50%?????18
??66%?????19
??75%?????19
??80%?????19
??90%?????20
??95%?????21
??98%?????23
??99%?????28
?100%?????64?(longest?request)
?

下載該資料的人也在下載 下載該資料的人還在閱讀
更多 >

評(píng)論

查看更多

下載排行

本周

  1. 1山景DSP芯片AP8248A2數(shù)據(jù)手冊(cè)
  2. 1.06 MB  |  532次下載  |  免費(fèi)
  3. 2RK3399完整板原理圖(支持平板,盒子VR)
  4. 3.28 MB  |  339次下載  |  免費(fèi)
  5. 3TC358743XBG評(píng)估板參考手冊(cè)
  6. 1.36 MB  |  330次下載  |  免費(fèi)
  7. 4DFM軟件使用教程
  8. 0.84 MB  |  295次下載  |  免費(fèi)
  9. 5元宇宙深度解析—未來的未來-風(fēng)口還是泡沫
  10. 6.40 MB  |  227次下載  |  免費(fèi)
  11. 6迪文DGUS開發(fā)指南
  12. 31.67 MB  |  194次下載  |  免費(fèi)
  13. 7元宇宙底層硬件系列報(bào)告
  14. 13.42 MB  |  182次下載  |  免費(fèi)
  15. 8FP5207XR-G1中文應(yīng)用手冊(cè)
  16. 1.09 MB  |  178次下載  |  免費(fèi)

本月

  1. 1OrCAD10.5下載OrCAD10.5中文版軟件
  2. 0.00 MB  |  234315次下載  |  免費(fèi)
  3. 2555集成電路應(yīng)用800例(新編版)
  4. 0.00 MB  |  33566次下載  |  免費(fèi)
  5. 3接口電路圖大全
  6. 未知  |  30323次下載  |  免費(fèi)
  7. 4開關(guān)電源設(shè)計(jì)實(shí)例指南
  8. 未知  |  21549次下載  |  免費(fèi)
  9. 5電氣工程師手冊(cè)免費(fèi)下載(新編第二版pdf電子書)
  10. 0.00 MB  |  15349次下載  |  免費(fèi)
  11. 6數(shù)字電路基礎(chǔ)pdf(下載)
  12. 未知  |  13750次下載  |  免費(fèi)
  13. 7電子制作實(shí)例集錦 下載
  14. 未知  |  8113次下載  |  免費(fèi)
  15. 8《LED驅(qū)動(dòng)電路設(shè)計(jì)》 溫德爾著
  16. 0.00 MB  |  6656次下載  |  免費(fèi)

總榜

  1. 1matlab軟件下載入口
  2. 未知  |  935054次下載  |  免費(fèi)
  3. 2protel99se軟件下載(可英文版轉(zhuǎn)中文版)
  4. 78.1 MB  |  537798次下載  |  免費(fèi)
  5. 3MATLAB 7.1 下載 (含軟件介紹)
  6. 未知  |  420027次下載  |  免費(fèi)
  7. 4OrCAD10.5下載OrCAD10.5中文版軟件
  8. 0.00 MB  |  234315次下載  |  免費(fèi)
  9. 5Altium DXP2002下載入口
  10. 未知  |  233046次下載  |  免費(fèi)
  11. 6電路仿真軟件multisim 10.0免費(fèi)下載
  12. 340992  |  191187次下載  |  免費(fèi)
  13. 7十天學(xué)會(huì)AVR單片機(jī)與C語言視頻教程 下載
  14. 158M  |  183279次下載  |  免費(fèi)
  15. 8proe5.0野火版下載(中文版免費(fèi)下載)
  16. 未知  |  138040次下載  |  免費(fèi)