Greetings!
I've been reviewing the codebase to get a clearer idea of the flow of handling, and have a few questions regarding process flow that aren't fully clear to me in terms of what lifetime expectations are when setting up a server flow with ServerBootstrap
:
-
I assume in that in all cases,
childChannelInit
is called for every established connection, and thus fory
established connections, there will be exactly that many references to a correspondingChannel/Pipeline/Context
combo (though they may be shared references should no changes to a pipeline occur on-the-fly). Correct me if my presumption is wrong. -
Is the relationship of
serverChannelInit
s to child channels thus 1 to y, x to y, or y to y?-
My understanding of
ServerBootstrap
on a surface level suggests that, essentially,serverChannelInit
would solely be responsible forChannel
operations that will occur on the initial incoming call to the bound port (and listening for a possible user quiescing event), andchildChannelInit
effectively handles all the actual communications. From appearances, only oneserverChannel
(for a specific instance ofServerBootstap
) will ever exist - EG, 1 to y.- Further, I assume in this case that while there is only one
serverChannel
, there may be numerousChannelHandlerContext
s that reference that one channel
- Further, I assume in this case that while there is only one
-
... Or will additional instances be generated by some mechanism when backlog triggers it, should the server channel that's "up" be actively in the process of handling a preceding connection? - EG, it might be 1 to y or it might be x to y
-
Final alternative, will server inits happen for every new incoming connection, regardless of duration, and essentially "shift" to the resultant child channel init, with a one-to-one correspondence? - EG, it will always be y to y
-
-
By comparison,
DatagramBootstrap
has no method of distinguishing between a "server" and "child" channel, so presumably every incoming envelope is handled by a distinct channel (which may or may not be reused? I'm unclear on this).-
This makes me think the situation with
ServerBootstrap
is more likely the x to y ratio, where server channels may "come up" to be reused as they detach connections to childChannels, but I have no idea. -
Possibly a
Datagram
-based server lacks thechildChannelInit
simply because it's assumed that such a server would be dealing with much smaller tasks and would be wasting overhead by switching to a child - EG, an NTP server?
-
-
Related; I notice that
ServerBootstrap
allows for distinctly binding the serverChannel(s) created to aEventLoopGroup
separate from the one on which childChannels are created, but I can find no reference to any codebase either in NIO or elsewhere using this init.- I presume this is intended as a possible optimization tool, where one might try to tweak real-world performance by ensuring the listening/server channels have a prioritized/dedicated
ELG
on a higher QoS level?
- I presume this is intended as a possible optimization tool, where one might try to tweak real-world performance by ensuring the listening/server channels have a prioritized/dedicated
For an arbitrary example, say this server is an http1.1 implementation and a client makes sixteen distinct requests from 4 remote ports on persistent connections; I would assume in this case that somewhere between 1 and 4 server channels would be init'd, and 4 child channels would be init'd.
Alternatively, if an http2 connection that takes sixteen requests on a single connection that's multiplexed , only created one server and one child channel will be created (though the child channel itself may indeed have additional child channels for multiplexing, but these, I don't believe, are functionally the same as the ServerBoostrap
child channels, more like "grandchildren".)
In both cases, once a/the server channel has initially set up the connection and IP tuple, it is never in the path of incoming/outgoing traffic that's established, I believe - that goes directly to the child channels? Ergo only a childChannel
will ever have a remoteAddress
set, not a serverChannel
?