How mohamedshyzeghori/webserver works
Project Type and Purpose
• This is a Java‐based server application demonstrating three threading models (single‐threaded, multi‐threaded, thread‐pool) for handling TCP client connections.
• It’s a back-end service (no UI) with external load-generation via Apache JMeter or a custom Java Client.
Main Components
• Client(s) – can be the provided Client.java or JMeter acting as an external load generator.
• Server Core – three interchangeable modules under WEBSERVER/SingleThreaded, MultiThreaded, ThreadPool.
• Thread Manager – either the single main thread, per-connection thread factory, or fixed thread pool executor.
• Network Interface – TCP listener bound to port 8010, accepting Socket connections.
• Business Logic – simple greeting response written to the socket’s OutputStream.
• Build/Deployment – Java compiler (javac), Maven for dependencies, IDE project files (.iml), output directory (out/production).
Relationships and Interactions
• Client → TCP Socket → Server Listener
• Server Listener → hands off the socket to the Thread Manager
• Thread Manager → invokes a Worker Thread/Task → executes Business Logic → writes response back through the same socket
• JMeter (external) → simulates N concurrent clients → collects response times → feeds back into performance metrics
Architectural Patterns and Design Principles
• Single‐Threaded: request lifecycle all in one thread (no concurrency).
• Multi‐Threaded: “one thread per client” model, unlimited thread creation.
• Thread Pool: fixed-size java.util.concurrent.ExecutorService to cap concurrency and reuse threads.
• Separation of Concerns: network I/O, thread management, and business logic are distinct responsibilities.
– Left: Clients (Custom Java Client, JMeter Load Generator)
– Center: Server Listener & Thread Manager Module (choose one of the three models)
– Right: Worker Threads executing Business Logic
c. Alternatives:
d. Technologies:
– Label Java 21, Maven dependency management
– Note port 8010, TCP Sampler in JMeter, ThreadPool size (configurable)