GitHub - webcpp/mongols: A network library for c++
source link: https://github.com/webcpp/mongols
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
README.md
mongols
a library for c++
Libevent, libev and libuv are outdated.
dependency
- linux
- gcc (-std=c11)
- g++ (-std=c++11)
feature
epoll or epoll + multi-threading + multi-process
- tcp sever
- http server
- websocket server
- web server
- leveldb server
- lua server
- sqlite server
- medis_server (like redis but support sqlite and leveldb)
- utils
install
make clean && make -j2 && sudo make install && sudo ldconfig
usage
pkg-config --libs --cflags mongols
leveldb_server usage
-
successful: 200
-
failed: 500
-
POST
curl -d'key=value' http://host/key
-
GET
curl http://host/key
-
DELETE
curl -X DELETE http://host/key
sqlite_server usage
- successful: 200
- failed: 500
- sql_type: cmd,transaction,query
- sql: SQL statement
- result: JSON
POST curl -d 'sql_type=x' -d 'sql=sql_statement' http://127.0.0.1:9090/
example: curl -d'sql_type=query' -d'sql=select * from test limit 3;' http://127.0.0.1:9090/
result: {"error":null,"result":[{"id":1,"name":"a"},{"id":2,"name":"b"},{"id":3,"name":"c"}]}
benchmark
2 core,4 GB,linux mint 18,2 thread:
http
ab -kc 10000 -n 500000 -H 'Connection: keep-alive' http://127.0.0.1:9090/
wrk -t 50 -d 30s -c 10000 -H 'Connection: keep-alive' http://127.0.0.1:9090/
web
multi-process web
medis
example
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK