I have some questions regarding how the SmartThings platform works.
Is the system the SmartThings cloud platform is based on Cassandra? If yes, are there any core parts of Cassandra that have been modified? In particular, is it still eventual consistency or something else?
How are incoming events/requests received at the cloud infrastructure? Is there a queue created for each SmartApp? Is there a queue that receives all events? How does the infrastructure deal with concurrency; does execution of each request need to happen strictly in the order that it was received? Is there some ordering guarantee?
If there is no strict ordering guarantee (i.e. this means SmartApps can overlap their executions and are not serial), SmartApp instances executed concurrently could compete against each other and finish in a different order (race conditions). Is there a mechanism (e.g. scheduling) that guarantees that this doesn’t happen?
In general, at which level does scheduling happen? How are different events scheduled for SmartApps and devices from the same user? What is the policy and how does it affect i) execution of requests that belong to separate SmartApps? Example: Event A happens first and triggers SmartApp 1 to execute and Event B triggers SmartApp 2 to execute. Is there any way SmartApp will be scheduled to execute first?
How does the policy affect ii) execution of requests that belong to the same SmartApp? Example: Event A happens first and triggers SmartApp X to execute and Event B triggers SmartApp X to execute as well. Is there any way SmartApp X will handle event B first due to scheduling?
In the documentation, two mechanisms are provided to manage persistent storage, State and Atomic State. It would very helpful to know how State and Atomic State are implemented. What does happen in the background? For Atomic State, is the API calling for some locking mechanism in the underlying system (e.g. Cassandra)?
I also have a question regarding how the Hub works. Once the hub receives a request/command from the cloud platform, is that put into a queue to guarantee that order is preserved? Does the hub have multiple threads to serve requests or serves one such request/command at a time? If there are multiple threads, does scheduling of these threads guarantee completion in order? Do events received concurrently get dropped?