Distributed systems – Patterns

Distributed systems

They are all around us like Google, Facebook, Amazon. A distributed system is a system whose components are located on different networked computers(Nodes), which communicate and coordinate their actions to one another. The components interact with one another in order to achieve a common goal.

Basic architectural patterns

3 tier model

This architecture is directly derived from the classic monolithic structure which the majority of companies use. The figure shows a typical structure of how a distributed system will look like. At tier 1 you will see a load balancer followed by a scalable middleware at tier 2 and a scalable database. Here we have NodeJs at the middleware and a Cassandra in the database. The middleware must be stateless in this architecture. 

Walmart uses this structure today.

Sharded 

This pattern is again a modification of the current monolithic structure, converting it to a usable distributed system. In this pattern, the entire application itself is scaled as per a defined partition. Slack is one of the applications which uses this pattern and each organization in slack is nothing but one Shard(One whole application). The application in itself is complete and doesn’t use or interact with other applications.

Lambda

You will find this pattern typically in an analysis driven system. Twitter uses this pattern. It receives continuous streams of incoming events(Tweets in Twitter).This event is fed into a stream and a database. Every event is processed twice one for direct events and second for indirect events. I.e. In case of twitter direct events represents notifications, timeline updates, etc and the indirect event represents the trends. The downside of this system is to write every computation twice. 

Streaming/ Event-driven

This is actually not a pattern rather a way of communication and management inside a distributed system. It replaces the conventional calling and 2PC to an event-driven mechanism. It eradicates the complex calls to one another and streams it. All the nodes complete their tasks when an event is fired which they are subscribed to and fires an event based on their process which then causes the flow of events. Uber, Netflix are some of the applications using this pattern which successfully process more than 3trillion requests per day.

Finally, one must carefully think about the pattern before starting a project. It is a cumbersome task to alter existing system towards a pattern. Every pattern has its uses, pros and cons. You have to select based on your requirements.