Threads
In the FineDB server, there is 3 different kind of threads:
- The main thread, which creates the other ones and then listen for incoming connections.
- The writer thread, which role is to write asynchronously into the LMDB storage engine.
- The communication threads. They handle communication with clients, interpreting their requests. Readings and synchronous writings are done directly; asynchronous writings are delegated to the writer thread.
Communication between threads
There is two nanomsg communication streams:
- The first one is a PUSH/PULL fanout load-balanced stream. The main thread pushes there the file descriptor of every new incoming connection. Nanomsg distributes automatically these messages to the communication threads.
- The second one is a PUSH/PULL fanin data stream. Communication threads use it to send data to the writer thread.
Diagram
- TCP socket listening for new connections
- Nanomsg connection, used to transmit the incoming client connections to the connection threads.
- Reading operations are done directly on the LMDB storage engine.
- Synchronous writing operations are done directly too.
- Nanomsg connection, used to transmit asynchronous writings to the writer thread.
- The writer thread access directly to the LMDB storage engine.