Posts

What are Master and Slave databases and how does pairing them make web apps faster?

What are Master and Slave databases and how does pairing them make web apps faster? A database is "slaved" to a "master" when it receives a stream of updates from the master in near real-time, functioning as a copy. The "slave" must simply apply the changes that the master validated and approved. In principle, one could create a master-slave setup by transferring files really fast from one server to the other; but in practice, each database has its own specialized replication protocol. There are many reasons a replica makes queries return faster. One is that the master's CPU is less burdened by queries while the replica's CPU is less burdened by writes; so there is more CPU available to do work. Another is that data, while nominally stored to disk, is cached in RAM when that is possible; and indeed the OS does this whether the database asks for it or not and can be unpredictable about it. On the master, recently written portions of the database ...

CAP Theory

CAP Theorem CAP Theorem states that in a distributed system, it is impossible to simultaneously guarantee all of the following: •  Consistency •  Availability •  Partition Tolerance A plain english introduction to  CAP  Theorem 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, lets 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 in remembering things. And you’re sooo 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 news paper ad which explains your idea Remembrance Inc! - Never forget, ...

Storage Scalability ->Vertical scaling and Horizontal scaling Sharding

Storage Scalability 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. Post replication, 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 eventual consistent model implies that all machines will have the same data eventually. Its 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. ...
class animals {    public:    int weight ;    string name;    string sound;    public :    void setName(string name){   this->name=name;   }    string getName(){     return this->name;    }       void setSound(string sound){     cout<<sound<<endl;   this->sound=sound;     }    string getSound(){     return this->sound;    }     void setWeight(int weight){     if(weight>0)     this->weight=weight;     else cout<<"weight should be more than 0";    }     int getWeight(){     return this->weight;    } }; class cat : public animals  {   public :   cat():animals()    {     setSound("meoooow");  } ...

c++ problems and solutions related to oops

1-> How to publicly inherit from a base class but make some of public methods from the base class private in the derived class? ans- 1) You can use public inheritance and then make bar private: class Base { public : void foo (){} void bar (){} }; class Derived : public Base { private : using Base :: bar ; }; 2) You can use private inheritance and then make foo public: class Base { public : void foo (){} void bar (){} }; class Derived : private Base { public : using Base :: foo ; }; Note: If you have a pointer or reference of type Base which contains an object of type Derived then the user will still be able to call the member.