Giter VIP home page Giter VIP logo

web-server's Introduction

web-server

I upgraded a basic web server that has a single thread of control to make it multi-threaded.

Multi-threaded:

  • The server consists of a master thread that begins by creating a pool of worker threads, the number of which is specified on the command line. The master thread is then responsible for accepting new HTTP connections over the network and placing the connection descriptor in the queue.
  • Each worker thread can handle both static and dynamic requests. A worker thread wakes when there is an HTTP request in the queue; when there are multiple HTTP requests available, it should pick the oldest request in the queue.
  • Once the worker thread wakes, it performs the read on the network descriptor, obtains the specified content (by either reading the static file or executing the CGI process), and then returns the content to the client by writing to the descriptor. The worker thread then waits for another HTTP request. This is implemented using condition variables and no busy-waiting.

Overload Handling:

  • block: The code thread blocks until a buffer becomes available.
  • drop_tail: The code drops the new request immediately by closing the socket and continues listening for new requests.
  • drop_head: The code drops the oldest request in the queue that is not currently being processed by a thread and adds the new request to the end of the queue.

Usage Statistics:

  • The web server collects a variety of statistics; per-request and per-thread basis.

Use the makefile to compile.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.