Why should you consider distributing your Web App? 
Tags: beginners, webdev, kubernetes, learning
Published: 2019-04-02 11:59:37

---
title: Why should you consider distributing your Web App? 
published: true
description: Distributed systems, stream processing, and Big Data systems are everywhere. but WHY do we need them? 
cover_image: https://cdn.pixabay.com/photo/2017/04/02/17/24/long-cargo-truck-2196355_960_720.png
tags: beginners , webdev , kubernetes , learning
---



Follow me on [Twitter](https://twitter.com/AdiPolak), happy to take your feedback and comments.


#####_Distributed systems, stream processing, and Big Data systems are taking the headlines. BUT, WHY do we need them?_  

- 4 Reasons for building distributes system and how Kubernetes can help us get started. 


#### What is a web app?

A web app is an application that can be accessed over the network, usually over the network via a web browser. It contains both a server and a client. The client contains the user interface and client-side logic. The server usually contains the database, some logic and can use other servers. At the server-side, we often define an API for the server and client to communicate through. This is the language they are communicating. The server can communicate with other servers using the same API as well. There are many ways to define API, the one I like most is by [Petr Gazarov](https://medium.com/r/?url=https%3A%2F%2Fmedium.freecodecamp.org%2Fwhat-is-an-api-in-english-please-b880a3214a82). 

![](https://cdn.techterms.com/img/lg/client-server_model_1253.png)

#### That’s all nice, but what is distributes web app and why do I need it? 

A distributed system is a system with components on multiple machines that  communicate over a network by passing messages to one another. Its components often located on a different network of computers and they communicate via passing messages to one another. The messaging protocol and the way they communicate is defined by a specific API that is built to support this cause. Using the message system they coordinate their actions using a **communication model**. A common model of communication is the _master/slave._ Where we have one _master_ that control the flow and multiple _slaves_ that acts upon the tasks given from the master_._ This communication model is implemented in Apache Spark, it is called driver and executors, where the driver is the master, and the executors are the slaves. 

There are multiple ways of architecting a distributed system with various communications models like [client–server](https://medium.com/r/?url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FClient%25E2%2580%2593server_model "Client–server model"), [three-tier](https://medium.com/r/?url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FThree-tier_%28computing%29 "Three-tier (computing)"), [_n_-tier](https://medium.com/r/?url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FMultitier_architecture "Multitier architecture"), or [peer-to-peer](https://medium.com/r/?url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FPeer-to-peer "Peer-to-peer"); or categories: [loose coupling](https://medium.com/r/?url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FLoose_coupling "Loose coupling"), or [tight coupling](https://medium.com/r/?url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FComputer_cluster "Computer cluster"). But, today we are going to focus on the **why**. 

#### So, Why do we need a distributed system?

Let’s say that we build a web app. At the beginning we serve 100 happy customers, our product grows and within a year, we now need to serve 10 million customers. We would like to serve these customers as fast as possible, without them feeling latency. On top of that, we would like the app to be available at all times, no matter what. And, we want the app to perform its intended functionality fully, meaning, we need Reliability.

###**4 Reasones for architecting a distributed system:**

#### 1 - Availability

It is the probability that a system is available at any given time. Making sure that if one server fails, we have another server to replace it without the user noticing any delay. Even better, constantly monitoring the server for making sure it is available for upcoming requests from the customers. Having multiple components ready to take on the role helps make the system highly available.

#### 2 - Scalability

There are multiple components to scalability scalable databases, and system that can hold and manage petabytes of data, and/or a system that can handle millions of concurrent requests. In each of these cases, we can use a distributed approach to build a system that can scale when we need it to. Adding components to the system shouldn’t be hard if we architect our system for scale from the beginning. 

#### 3 - Reliability

The probability that a system will produce correct outputs. A reliable system does not silently continue and deliver results with missing or corrupted data. Instead, it detects failure, fires an alert and, if possible, recovers from it. Building a system with reliability in mind is making sure that our customers can rely on the response and data provided by the system. This might include that they are building their business on, like biz dev analysis, risk management analysis for financial institutions and more. As we make a system more reliable we reduce the chance of it failing within a specific time period. We do this by increasing the  redundancy or replication of the components and manage them for high availability, making them more reliable.

#### 4 - Transparency

The customers are not aware of the distributed system, since they interact with the products the same as they would with a centralized system. Meaning the distribution of the system is isolated from the customer. We gain all the benefits of a distributed system without the customer feeling it. 

#### Now that we understand the WHY, lets hit the WHAT, What is the easiest way to start?

![Alt Text](https://media.giphy.com/media/4abqdfTBWYD5KsUrBg/source.gif)



A managed Kubernetes service such as  [AKS](https://medium.com/r/?url=https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Faks%2Fintro-kubernetes%2F%3FWT.mc_id%3Ddevto-blog-adpolak) can provide a solid platform for building a distributed system. We define the number of nodes — which are the number of Azure Virtual Machines and Azure Kubernetes Service takes care of the control plane, or master nodes, which are managed and provided for free. From the picture, you can see a very simplified diagram of the worker nodes of our Kubernetes cluster that host our web app which our customer will access. A customer request is received by the load balancer and delivered to our web application which has its components distributed across our pool of worker node. The components can be replicated and our pool of nodes can grow or shrink according to the load we have.


![](https://cdn-images-1.medium.com/max/1600/1*J4BypEYTe_qpOymFFexvGg.png)



In [this post](https://dev.to/azure/virtual-kubelet-with-spring-boot-and-the-jvm-what-is-it-and-how-you-start-48mj) you will learn all the details of how we can create a distributed web application :) 

#### Reference:

*   [Wikipedia - Reliability, availability and serviceability](https://en.wikipedia.org/wiki/Reliability,_availability_and_serviceability)
* [Intro to AKS](https://docs.microsoft.com/en-us/azure/aks/intro-kubernetes/?WT.mc_id=devto-blog-adpolak)
* [Why K8S is awesome](https://medium.com/@jandavid.staerk/why-kubernetes-is-awesome-9f7ff0186996)