Our intention is to build good, stable and secure software. This implies detailed documentation.
Do not forget: keep the clean code paradigm in mind.
The following document describes the Base-Layout of FalconAS / HTTP/1.2, its Base Components
and Insfrastructural Layout.
The following components are referenced throughout the documentation.
Logical Component Names used in documentation and the C++ Abstraction Model sometimes do not match.
XML Configuration Handling. C++ Transformation.
Main Server Loop.
Client / Connection Handler.
Static Files / Virtual Host Handler.
Python Application Server Process Handler.
Result processing process (fork).
Result Thread Distributor.
Due to looping on Result sendfile(), write() and Header Processing, each ClientFDs requests (plural) will be processed by a single Posix Thread.
This also guarantees that multiple repeated result writes (in case of congestion) always will be processed in serial order.
Big results using multiple writes are sent in the correct order as well.
Result Ordering will be done for the following types:
- Static Files, sendfile()
- Application Server Results (JSON), write()
Result Ordering. Results must be sent in the exact order how they arrived. The Result Ordering Class keeps track of dependend ClientFD Requests / Request Nr. and related.
No order needed. Our implementation appends the "Request-UUID" HTTP Header to the HTTP Response.
Due to the Python Global Interpreter Lock the Main Server, ResultProcessor and each Application
Server Process are implemented using Unix Processes.
Data Sharing (Requests, Synchronization) is done by Shared Memory and User Space Atomic Locks (Kernel Mutex less).
+-----------------------+-----------------------+-----------------------+-----------------------+
| Server Process | AS Process 1 | AS Process x | Result Processor |
| | Python Interpreter | Python Interpreter | |
+-----------------------+-----------------------+-----------------------+-----------------------+
| Shared Mem |
| - StaticFS Requests |
| - AS Metadata |
| - AS Requests |
| - AS Results |
+-----------------------------------------------------------------------------------------------+32bit memory addresses used for simplicity.
Address Type Descr Default
0x00000000 atomic_uint16_t StaticFSLock 0
0x00000002 uint16_t RequestCount 0
-- Req 1 Metadata ---------------------------------------------------
0x00000004 uint16_t ClientFD Nullptr
0x00000006 uint16_t HTTPVersion Nullptr
0x00000008 uint16_t RequestNr Nullptr
0x0000000a uint16_t PayloadLength Nullptr
0x0000000c char[] char[LenReq1] Nullptr
-- Req 2 Metadata ---------------------------------------------------
0x0000000c+LenReq1 uint16_t ClientFD Nullptr
0x0000000e+LenReq1+2 uint16_t HTTPVersion Nullptr
0x00000010+LenReq1+4 uint16_t RequestNr Nullptr
0x00000012+LenReq1+6 uint16_t PayloadLength Nullptr
0x00000014+LenReq1+8 char[] char[LenReq2] NullptrAddress Type Descr Default
-- AS 1 Metadata ---------------------------------------------------
0x00000000 atomic_uint16_t CanRead 0
0x00000002 atomic_uint16_t WriteReady 0
0x00000004 uint16_t ClientFD Nullptr
0x00000006 uint16_t HTTPVersion 1
0x00000008 uint16_t HTTPMethod 1
0x0000000a uint16_t ReqNr 1
0x0000000c uint32_t ReqPayloadLen Nullptr
0x00000010 uint32_t ResPayloadLen Nullptr
-- AS 2 Metadata ---------------------------------------------------
0x00000014 atomic_uint16_t CanRead 0
0x00000016 atomic_uint16_t WriteReady 0
0x00000018 uint16_t ClientFD Nullptr
0x0000001a uint16_t HTTPVersion 1
0x0000001c uint16_t HTTPMethod 1
0x0000001e uint16_t ReqNr 1
0x00000020 uint32_t ReqPayloadLen Nullptr
0x00000024 uint32_t ResPayloadLen NullptrAddress Type Descr Default
-- AS 1 Payload -----------------------------------------------------
0x00000000 char[] char[LenReq] Nullptr
-- AS 2 Payload -----------------------------------------------------
0x00000000+SegmentSize char[] char[LenReq] Nullptr-- AS 1 Payload -----------------------------------------------------
0x00000000 char[] char[LenRes] Nullptr
-- AS 2 Payload -----------------------------------------------------
0x00000000+SegmentSize char[] char[LenRes] Nullptr