Database connector handling multiple clients query request and routing to the different databases asynchronously.
Goals:
- Fewer resources: No need of threads for each connection.
- Less overhead: Less context switching.
Single-threaded approach:
- event-based, non-blocking paradigm
- avoiding context switches, locks, and blocking
Changes made:
- Once submission is completed, query response is sent to the client by selecting thread from the pool.
- Using threads from the threadpool minimizes the overhead due to thread creation. Thread objects use a significant amount of memory, and in a large-scale application, allocating and deallocating many thread objects creates a significant memory management overhead.
- Main-thread task is just to listen query from the client and call async-db-access API.
TODO:
- Implement ConnectionPool feature
- Make changes to capture latency and throughput
- Exception handling, sending exception back to the client