Git Product home page Git Product logo

httpechoserver's Introduction

HttpEchoServer

[Oogway] Create a simple multithreaded Http echo server

Write a minimal multi-threaded HTTP echo server that accepts connections in a main thread, hands connections to an available worker thread from a thread pool, parses and processes the POST request in the worker thread, ignores path specified in the POST, and sends a 200 OK response with the same content-type header and payload from the request. In other words, echo back the content to the client.

Project done in NetBeans IDE (Windows).

Download NetBeans from : https://netbeans.org/downloads/

Setting up the project:

  1. Import the entire project in your NetBeans IDE and build and run it.
  2. Clone the Client Program for testing the working of the HttpEchoServer. https://github.com/Talina06/HttpTestClient.git

Test Scenarios:

Test Scenario 1: Testing multi-threaded execution and blocking of accept call when all threads are busy.

  1. Configuration: src/httpechoserver/Config.java
  • maxThreadCount = 1 //i.e maximum one thread processes a single request at a time in the ThreadPool.
  • backlogCount = 2 //i.e 2 requests are waiting while the ThreadPool is full.
  1. Start around 10 instances of the HttpTestClient program.
  2. The server will process one request at a time, and put 2 requests in the pendingQueue.
  3. Each time a thread is available, the server pops a request from the pendingQueue and pushes the next incoming request onto the pendingQueue.
  4. While the above is happening, the next incoming requests are not accepted by the server, until queue has space available.

Test Scenarios 2: Testing Clean Server Termination.

  1. Same configuration as Test 1.
  • shutDownTime = 10 Seconds. // i.e: time limit for all threads to shutdown gracefully.
  1. Add a System.exit() call after processing one request in the WorkerThread class.
  2. Start around 3-4 instances of the HttpTestClient program.
  3. When the server processes the first request, it exits due to the System.exit() call.
  4. This invoked the shutdownhook and the server proceeds to close all active/waiting threads in the ThreadPool.
  5. Then, the Server Socket is closed.

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.