Janus WebServer is a high-performance web server built with modern C++ and designed with Reactor pattern and event-driven architecture. The project aims to provide an efficient, stable, and extensible network server framework.
The project is currently under development and implementing features step by step according to a detailed roadmap.
- π epoll-based IO multiplexing
- β‘ Event-driven Reactor pattern
- π§΅ Multi-threading support (One Loop Per Thread)
- π¦ RAII resource management mechanism
- π HTTP protocol support
- π§ High-performance buffer design
- π Modern C++ features
βββββββββββββββββββ
β HttpServer β Application Layer: HTTP protocol parsing and handling
βββββββββββββββββββ
βββββββββββββββββββ
β TcpServer β Transport Layer: TCP connection management
βββββββββββββββββββ
βββββββββββββββββββ
β EventLoopPool β Threading Model: Thread pool management
βββββββββββββββββββ
βββββββββββββββββββ
β EventLoop β Core Layer: Event loop
βββββββββββββββββββ
βββββββββββββββββββ
β Epoll β System Layer: IO multiplexing
βββββββββββββββββββ
βββββββββββββββββββ
β Socket/Channel β Foundation Layer: Socket encapsulation
βββββββββββββββββββ
Implement basic socket encapsulation and build the foundation of RAII resource management model.
Build the core components of event-driven architecture, including Channel, Epoll and EventLoop.
Implement object-oriented connection management and introduce Buffer to solve packet sticking problems.
Add HTTP protocol parsing capabilities to build a complete HTTP server.
Implement multi-threading model to improve concurrent processing capability of the server.
Performance optimization and implementation of advanced features.
See detailed roadmap in ROADMAP.md
- C++20 or higher
- Linux system (epoll support)
- CMake 3.10+
- Python 3.6+ (for test scripts)
# Clone the project
git clone ssh://git@ssh.github.com:443/yedou37/WebServer.git
cd janus-webserver
# Create build directory
mkdir build && cd build
# Compile the project
cmake ..
make./janus-webserverBy default, the server listens on port 8080.
# Create virtual environment
python3 -m venv venv
# Activate virtual environment
source venv/bin/activate
# Install test dependencies
pip install -r requirements.txt
# Deactivate virtual environment
deactivateEnsure the server is running, then execute tests:
# Activate virtual environment
source venv/bin/activate
# Run integration tests
python -m pytest tests/integration_test/ -v
# Run specific test
python tests/test_concurrency.py
# Deactivate virtual environment
deactivatesrc/
βββ base/ # Base components
β βββ Macros.hh # Common macro definitions
β βββ Buffer.cpp # Data buffer
βββ net/ # Network modules
β βββ Socket.cpp # Socket encapsulation
β βββ InetAddress.cpp # IP address encapsulation
β βββ Channel.cpp # Event channel
β βββ Epoll.cpp # epoll operation encapsulation
β βββ EventLoop.cpp # Event loop
β βββ EventLoopThread.cpp # Event loop thread
β βββ EventLoopThreadPool.cpp # Thread pool
β βββ TcpConnection.cpp # TCP connection
β βββ TcpServer.cpp # TCP server
βββ http/ # HTTP module (planned)
βββ main.cpp # Main program entry
Issues and Pull Requests are welcome to help improve the project. Before contributing code, please ensure:
- Follow the existing code style of the project
- Add appropriate test cases
- Update relevant documentation
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by the muduo network library
- Referenced design ideas from CS144 Computer Networking course
Janus WebServer - Building high-performance web servers with modern C++