{"id":15027806,"url":"https://github.com/linyacool/webserver","last_synced_at":"2025-05-14T06:12:13.021Z","repository":{"id":37448354,"uuid":"119961591","full_name":"linyacool/WebServer","owner":"linyacool","description":"A C++ High Performance Web Server","archived":false,"fork":false,"pushed_at":"2023-09-27T14:35:07.000Z","size":2526,"stargazers_count":7962,"open_issues_count":109,"forks_count":2127,"subscribers_count":73,"default_branch":"master","last_synced_at":"2025-04-03T14:42:04.023Z","etag":null,"topics":["cpp11","epoll","http","http-server","raii","reactor","thread-pool","webserver"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/linyacool.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-02-02T09:29:37.000Z","updated_at":"2025-04-03T03:27:51.000Z","dependencies_parsed_at":"2022-07-11T22:01:16.562Z","dependency_job_id":"8e688729-f3a3-4bc9-8c94-b9f99a2eda51","html_url":"https://github.com/linyacool/WebServer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linyacool%2FWebServer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linyacool%2FWebServer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linyacool%2FWebServer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linyacool%2FWebServer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/linyacool","download_url":"https://codeload.github.com/linyacool/WebServer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248313306,"owners_count":21082836,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp11","epoll","http","http-server","raii","reactor","thread-pool","webserver"],"created_at":"2024-09-24T20:07:05.459Z","updated_at":"2025-04-10T23:23:41.457Z","avatar_url":"https://github.com/linyacool.png","language":"C++","readme":"# A C++ High Performance Web Server\r\n\r\n[![Build Status](https://travis-ci.org/linyacool/WebServer.svg?branch=master)](https://travis-ci.org/linyacool/WebServer)\r\n[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://opensource.org/licenses/MIT)\r\n\r\n  \r\n## Introduction  \r\n\r\n本项目为C++11编写的Web服务器，解析了get、head请求，可处理静态资源，支持HTTP长连接，支持管线化请求，并实现了异步日志，记录服务器运行状态。  \r\n\r\n\r\n\r\n| Part Ⅰ | Part Ⅱ | Part Ⅲ | Part Ⅳ | Part Ⅴ | Part Ⅵ |\r\n| :--------: | :---------: | :---------: | :---------: | :---------: | :---------: |\r\n| [并发模型](https://github.com/linyacool/WebServer/blob/master/并发模型.md)|[连接的维护](https://github.com/linyacool/WebServer/blob/master/连接的维护.md)|[版本历史](https://github.com/linyacool/WebServer/blob/master/%E7%89%88%E6%9C%AC%E5%8E%86%E5%8F%B2.md) | [测试及改进](https://github.com/linyacool/WebServer/blob/master/测试及改进.md) | [项目目的](https://github.com/linyacool/WebServer/blob/master/%E9%A1%B9%E7%9B%AE%E7%9B%AE%E7%9A%84.md) | [面试问题](https://github.com/linyacool/WebServer/blob/master/%E9%9D%A2%E8%AF%95%E9%97%AE%E9%A2%98.md)\r\n\r\n## Envoirment  \r\n* OS: Ubuntu 14.04\r\n* Complier: g++ 4.8\r\n\r\n## Build\r\n\r\n\t./build.sh\r\n\r\n## Usage\r\n\r\n\t./WebServer [-t thread_numbers] [-p port] [-l log_file_path(should begin with '/')]\r\n\r\n## Technical points\r\n* 使用Epoll边沿触发的IO多路复用技术，非阻塞IO，使用Reactor模式\r\n* 使用多线程充分利用多核CPU，并使用线程池避免线程频繁创建销毁的开销\r\n* 使用基于小根堆的定时器关闭超时请求\r\n* 主线程只负责accept请求，并以Round Robin的方式分发给其它IO线程(兼计算线程)，锁的争用只会出现在主线程和某一特定线程中\r\n* 使用eventfd实现了线程的异步唤醒\r\n* 使用双缓冲区技术实现了简单的异步日志系统\r\n* 为减少内存泄漏的可能，使用智能指针等RAII机制\r\n* 使用状态机解析了HTTP请求,支持管线化\r\n* 支持优雅关闭连接\r\n \r\n## Model\r\n\r\n并发模型为Reactor+非阻塞IO+线程池，新连接Round Robin分配，详细介绍请参考[并发模型](https://github.com/linyacool/WebServer/blob/master/并发模型.md)\r\n![并发模型](https://github.com/linyacool/WebServer/blob/master/datum/model.png)\r\n\r\n## 代码统计\r\n\r\n![cloc](https://github.com/linyacool/WebServer/blob/master/datum/cloc.png)\r\n\r\n\r\n## Others\r\n除了项目基本的代码，进服务器进行压测时，对开源测试工具Webbench增加了Keep-Alive选项和测试功能: 改写后的[Webbench](https://github.com/linyacool/WebBench)\r\n\r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinyacool%2Fwebserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinyacool%2Fwebserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinyacool%2Fwebserver/lists"}