ndt-server
ndt-server copied to clipboard
ndt7: design better/simpler channels structure
I was too excited about channels and wrote pipeline code. Also, requirements changed. So, now we not necessarily need to have this pipeline code and we can save some channels. Saving some channels is not just useful to improve the beauty of the code base; as discussed with @darkk in a recent PR and offline, the current structure does not behave well when there are proxies/middleboxes.
The current code is like in the following diagram:
Because now the saver is not streaming to disk, there is less need to have a saver goroutine to which we send data. It would actually seem more proper to store measurements inside the measurer and the receiver and wait for the end of the nettest to assemble the final JSON object. This allows us to save some channels.
The fix to this first issue consists in removing the channels and synchronising the goroutines running in the background by using some other mechanism, e.g., a waitgroup.
A second issue of this code is that the measurer may block sending on the channel when the sender is blocked on a non writeable socket. This prevents us from collecting measurements.
The quick fix to this issue is to make writing on the channel between the measurer and the sender nonblocking, such that we never block the sender.
gfr collaborated at the retreat, so also has some knowledge of this.