Wednesday 8 August 2018

A Distributed System Design Basics -- Newbie Level




What is Distributed System?

A Distributed System is an application that executes a collection of protocols to coordinate the actions of multiple processes on a network, such that all components cooperate together to perform a single or small set of related tasks.


Why build A Distributed System?


 There are lots of advantages including the ability to connect remote users with remote resources in an open and scalable way. When we say open, we mean each component is continually open to interaction with other components. When we say scalable, we mean the system can easily be altered to accommodate changes in the number of users, resources and computing entities.

Lets Dive into it...

Basic terminologies


We try to explain some of the terminologies in simple words. Lookup wiki for a more formal definition.
  • Replication: Replication refers to frequently copying the data across multiple machines. Postreplication, multiple copies of the data exists across machines. This might help in case one or more of the machines die due to some failure.
  • Consistency: Assuming you have a storage system which has more than one machine, consistency implies that the data is same across the cluster, so you can read or write to/from any node and get the same data.
    • Eventual consistency: Exactly what the name suggests. In a cluster, if multiple machines store the same data, an eventually consistent model implies that all machines will have the same data eventually. It's possible that at a given instance, those machines have different versions of the same data ( temporarily inconsistent ) but they will eventually reach a state where they have the same data.

  • Availability: In the context of a database cluster, Availability refers to the ability to always respond to queries ( read or write ) irrespective of nodes going down.
  • Partition Tolerance: In the context of a database cluster, cluster continues to function even if there is a “partition” (communications break) between two nodes (both nodes are up, but can’t communicate).
  • Vertical scaling and Horizontal scaling: In simple terms, to scale horizontally is adding more servers. To scale vertically is to increase the resources of the server ( RAM, CPU, storage, etc. ).
    Example: Let's say you own a restaurant which is now exceeding its seating capacity. One way of accommodating more people ( scaling ) would be to add more and more chairs (scaling vertically). However since space is limited, you won’t be able to add more chairs once the space is full.
    Another way of scaling would be to open new branches of the restaurant ( horizontal scaling ).
    Source: http://stackoverflow.com/questions/5401992/what-does-scale-horizontally-and-scale-vertically-mean
  • Sharding: With most huge systems, data does not fit on a single machine. In such cases, sharding refers to splitting the very large database into smaller, faster and more manageable parts called data shards.

Monday 6 August 2018

A plain English introduction to CAP Theorem - A Tale of Your Own Distributed System


Professional Definition...

CAP Theorem states that in a distributed system, it is impossible to simultaneously guarantee all of the following:
  • •  Consistency
  • •  Availability
  • •  Partition Tolerance
Let's dive in and see how and why the CAP system came into existence, with a very plain and simple analogy.
You’ll often hear about the CAP theorem which specifies some kind of an upper limit when designing distributed systems. As with most of my other introduction tutorials, let's try understanding CAP by comparing it with a real-world situation.

Chapter 1: “Remembrance Inc” Your new venture :

Last night when your spouse appreciated you on remembering her birthday and bringing her a gift, a strange Idea strikes you. People are so bad at remembering things. And you’re so good at it. So why not start a venture that will put your talent to use? The more you think about it, the more you like it. In fact, you even come up with a newspaper ad which explains your idea
Remembrance Inc! - Never forget,  even without remembering!
   Ever felt bad that you forget so much?  Don't worry. Help is just a phone away!
    When you need to remember something, just call 555--55-REMEM and tell us what you need to remember. For eg., call us and let us know of your boss's phone number, and forget to remember it. when you need to know it back.. call back the same number[(555)--55-REMEM ] and we'll tell you what's your boss's phone number.
   Charges : only $0.1 per request
So, your typical phone conversation will look like this:
  • Customer: Hey, Can you store my neighbor’s birthday?
  • You: Sure.. when is it?
  • Customer: 2nd of Jan
  • You: (write it down against the customer’s page in your paper notebook )Stored. Call us any time for knowing your neighbor’s birthday again!
  • Customer: Thank you!
  • You: No problem! We charged your credit card with $0.1
     

Chapter 2: You scale up:

Your venture gets funded by YCombinator. Your Idea is so simple, needs nothing but a paper notebook and phone, yet so effective that it spreads like wildfire. You start getting hundreds of call every day.
And there starts the problem. You see that more and more of your customers have to wait in the queue to speak to you. Most of them even hang up tired of the waiting tone. Besides when you were sick the other day and could not come to work you lost a whole day of business. Not to mention all those dissatisfied customers who wanted information on that day.
You decide it’s time for you to scale up and bring in your wife to help you.
You start with a simple plan:
  1. You and your wife both get an extension phone
  2. Customers still dial (555)–55-REMEM and need to remember only one number
  3. A PBX will route the customers call to whoever is free and equally

Blog Top Sites

Share Our Badge

 Computer Stuffs

Be Updated Its Free.

Subscribe via Email

Visitors Everyday



Website Security Test

Followers