In this 4th episode of my "device to cloud" series I'm introducing the notion of intermediated service-assisted connectivity for devices, whereby the gateway I introduced in the previous episodes gets split into an API layer that device controllers speak to through HTTP(S) and a protocol head layer that the device connects to and those two layers are interconnected with a set of queues. The added benefits of using this model is the ability to scale the two layers independently, it allows for load-balancing in both layers and it greatly improves the reliability of the overall communication path, including allowing to send commands or notifications to devices that are either connected through wireless radio links that may be occasionally degraded or unavailable for short periods of time or that are simply not always turned on. The code for the episode can be found at https://github.com/clemensv/D2C-Ep4-LedBlinker [Part 1] [Part 2] [Part 3] [Part 5]