Technical Architecture

The following diagram outlines the main components of Push Framework library :


Here are a few notes :

  • To efficiently manage iteraction with the system, the library uses Completion Ports (IOCP) for Windows Server and Two Epoll queues for Linux.  IOQueue acts like a Multiple-Producers Multiple Consumers Queue. The Demux module is responsible for stablishing the Consumers threads. These receive the system IO events (either completion events in case of Winddows, or readiness events in case of Linux) and process them.
  • The main thread is the one that manages the different part of the system : it launches the separate listening threads, the worker threads, the streaming threads and schedules periodic tasks like garbage collection, scrutinizing illegitimate connections, collecting performance measures. It also listens on the termination signal so it can stop all threads and clean all memory.
  • Listening is performed by a separate thread. Incoming connection requests are communicated to the Channels factory.  There happens the decision to associate the connection (PhysicalConnection) with a new Client object (LogicalConnection) or to attach it to an existing one (client reconnection identification).
  • The demux communicates the sending/receiving operation completion status back to the dispatcher. When a Write operation finishes, the intermediate Send buffer is examined for any outstanding data to be sent. If a Read operation completes, the dispatcher triggers de-serialization which in turn calls the protocol-defined de-framing and decoding code, then gives back control to the handle method of the Service object responsible of the incoming request type.
  • Most of execution time is spent on the available Service::handle methods. There you put the processing logic for each type of an incoming request. Naturally there you would push data to specific clients or to a broadcasting channel so the library implicitly streams the information to the list of client that are subscribed.
  • BroadcastStreamerManager launches a list of threads that stream broadcast messages from broadcast queues to subscribed LogicalConnections. So each streamers is responsible for a collection of clients.
  • Each broadcasting queue has 4 attributes : requireSubscription, maxPacket, priority and quota. if requireSubscription is false then all logged clients are implicitly subscribed to it. Otherwise, you must explicitely register each client you want.
  • Each broadcasting channel maintains a FIFO queue of the packets that are pushed into it. maxPacket is its maximum size. Ancient packets gets released when the queue is full. Avoiding the phenomenon of broadcast amplification ( uncontrollable increased memory consumption) comes at the cost of packet loss for those client with B(i) < F(j) where the B(i) is the available bandwidth between server and client i and F(j) is the fill rate of broadcasting channel j which i is subscribed to.
  • When the bandwidth between certain client x and server along with server’s degree of activity are such that not all data can be streamed out, the share of each broadcasting channel to which client x is subscribed is dependent on the priority and quotas attributes.
    • Suppose that broadcasting channels {Ci} are ordered in such way that if i < j => ( either Pi > Pj or (Pi  = Pj and Qi >= Qj)), P and Q being the priority and quota attributes
    • Let’s denote Fi the rate at which Ci is filled with new packets
    • Let’s assume S to be the total rate of broadcast data sent to client x
    • Further assuming that all outgoing messages have the same length

    THEN the share Si of broadcasting channel i is given by :

    \sum_{j, j<i}^{N}F_{j} > S \Rightarrow S_{i} = 0
    S_{i} =\left ( S- \sum_{j, j<i}^{N}F_{j}\right )*Q_{i} / \sum_{k, P_k=P_i}^{N}Q_k

  • The monitoring listener is started in case remote monitoring is enabled. It help accept connections from remote Dashboards so profiling infos are sent.

Continue to next article to learn about the business and developer benefits of this library.

Create PDF    Send article as PDF