Skip to content

This project is a lightweight, high-performance HTTP server implemented in pure C, designed for speed and efficiency. It uses epoll for scalable I/O multiplexing and a thread pool to take advantage of multi-core systems, allowing it to handle thousands of concurrent connections with minimal overhead.

License

Notifications You must be signed in to change notification settings

VryptLab/http-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

High-Performance HTTP Server in C

A lightweight, high-performance HTTP server written in pure C, designed for speed and scalability.
It uses epoll for efficient I/O multiplexing and a thread pool for concurrency, allowing it to handle thousands of simultaneous connections with minimal overhead.


Features

  • Ultra-lightweight: Minimal dependencies, written in pure C.
  • Fast Endpoints:
    • GET / → responds with raw text "OK".
    • GET /stats → responds with real-time JSON statistics:
      • total_connections: total number of connections since server start.
      • rps: requests per second (updated every second).
  • High Concurrency: Combines epoll with multi-threading for maximum throughput.
  • Optimized for Linux: Uses non-blocking sockets and atomic counters.

Build & Run

Requirements

  • Linux-based system
  • GCC (supporting C11 standard)
  • POSIX threads (pthread)

install

git clone https://github.com/VryptLab/http-server.git
make clear && make

Run

./server

By default, the server listens on port 8080.


Usage

  • Access the root endpoint:

    curl http://localhost:8080/

    Response:

    OK
    
  • Access server statistics:

    curl http://localhost:8080/stats

    Example response:

    {
      "total_connections": 42,
      "rps": 7
    }

Performance Notes

  • Designed to handle high numbers of concurrent connections using epoll (edge-triggered I/O).
  • Multithreaded with a thread pool equal to the number of CPU cores.
  • Atomic counters ensure safe, lock-free statistics tracking.

Use Cases

  • Benchmarking and load testing tools.
  • Educational reference for building scalable servers in C.
  • Lightweight alternative to heavy HTTP frameworks.

License

This project is released under the MIT License.
You are free to use, modify, and distribute it as long as the license terms are respected.

About

This project is a lightweight, high-performance HTTP server implemented in pure C, designed for speed and efficiency. It uses epoll for scalable I/O multiplexing and a thread pool to take advantage of multi-core systems, allowing it to handle thousands of concurrent connections with minimal overhead.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published