1 Star 8 Fork 3

青玉白露 / TinyWebServer

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

WebServer

A TinyWebServer implemented inC++11,经过webbenchh压力测试可以实现上万的QPS。

功能

  • 利用IO复用技术Epoll与线程池实现多线程的Reactor高并发模型;
  • 利用正则与状态机解析HTTP请求报文,实现处理静态资源的请求;
  • 基于小顶堆实现的定时器,关闭超时的非活动连接;
  • 利用RAII机制实现了数据库连接池,减少数据库连接建立与关闭的开销,同时实现了用户注册登录功能。

环境要求

  • Linux
  • C++11
  • MySql

目录树

.
├── code           源代码
│   ├── buffer
│   ├── config
│   ├── http
│   ├── log
│   ├── timer
│   ├── pool
│   ├── server
│   └── main.cpp
├── test           单元测试
│   ├── Makefile
│   └── test.cpp
├── resources      静态资源
│   ├── index.html
│   ├── image
│   ├── video
│   ├── js
│   └── css
├── bin            可执行文件
│   └── server
├── log            日志文件
├── webbench-1.5   压力测试
├── build          
│   └── Makefile
├── Makefile
├── LICENSE
└── readme.md

项目启动

配置Mysql数据库

// 建立yourdb库
create database yourdb;​
// 创建user表USE yourdb;
CREATE TABLE user(username char(50) NULL, password char(50) NULL)ENGINE=InnoDB;​
// 添加数据
INSERT INTO user(username, password) VALUES('name', 'password');

编译运行

make
./bin/server

致谢

Linux高性能服务器编程,游双著. @qinguoyi C++11的TinyWebServer

MIT License Copyright (c) 2021 一叶清漪 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

基于C++11实现的轻量级服务器开源项目,参考《linux高性能服务器编程(游双著)》。 展开 收起
C++
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C++
1
https://gitee.com/QingYuBaiLu_admin/TinyWebServer.git
git@gitee.com:QingYuBaiLu_admin/TinyWebServer.git
QingYuBaiLu_admin
TinyWebServer
TinyWebServer
master

搜索帮助