Distributed DataStores Basics

Scaling DBs & CAP Theorem:

CAP Theorem:  

  1. In distributed datastores the CAP theorem is used. There are different instances of DBs in the cluster and request/response are received/sent from the cluster. 
  2. In distributed data stores we have BASE properties, which means Basically Available Softstate Eventual Consistency.
  3. You can't have all 3 properties in your data store. So usually availability & partition tolerance are picked up over consistency. 
  4. Such systems have 'Weak' or 'Eventual' consistency. It means that read and write might be inconsistent for sometimes(minutes) till the data is propagated to all the systems in the cluster. 
    1. These distributed or NoSQL DBs are used by youtube and similar sites. However they can't be used for banking and financial applications. 
  5. The theorem states for: 
    1. Consistency: Data is same across the cluster. So Read/Write across any node of the cluster gives us the same data. 
    2. Availability: System needs to be highly available even if some nodes within a cluster goes down. 
      1. Now if master goes down then the read/write request will go to the slave. 
    3. Partition: If the connection between partition has failed then the system still should be up and running. 
      1. If partition/connection between M/S goes then if your most recent write might not be read correctly as latest updates are not read. 

Strategies to scale Relational DBs:

  1. This strategy is useful to scale RDBMS. Strategies: 
    1. Master-Slave: 
      1. Features: 
        1. One Master, Couple of Slaves.
        2. Write goes to the Master nodes.
        3. Read comes from the Slaves nodes.
        4. Replication from Master to Slave will happen async. 
        5. Async will result into inconsistency for the short term: 
          1. Ex: User writes to the Master and reads immediately. If data is not written to Slave then user will not be able to read his latest write thus getting stale data.
      2. Sharding: 
        1. All DBs are Master
        2. Data in DBs is spread across different servers based on some key and separation like A-I, J-Q, R-Z. Which means data starting from A-I will go to shard-1, J-Q will go to shard 2, and so on. 
        3. This ensured we have increased the availability by n times. 
        4. Problem: 
          1. If most request are between A-I then first DB will have all the requests. Thus we won't get enough load balancing. To solve this problem, we need to divide these requests between A-F, F-I. 
            1. To do that you need to take the DB down, divide it and switch it out. Its painful so its not an efficient DB scaling mechanism. 
          2. SQL joins might be required to get the data from different shards. 

How to approach Pricing questions in PM interviews

For new products: Pricing is amount that the customer is willing to pay. 
For existing products: Its competitor's price + accessories or customizations. Its called as competitive pricing. 
For new and existing products, you can use cost based pricing. 

Best way to find the price: Vary it over the period of time and based on volume. 
If you can't price the product then you can take customer survey or use some data to come up with expectations. 

For pricing questions, approach it as:
1. Find out cost price and mark it as such. 
2. Look for competitive price and mark it up or down based on it. Make sure to mark it above cost price. 
3. Evaluate supply and demand over the period of time and come up with ideal pricing. 

White Spaces

Hello World
public class Test  {
    static char a[] = {'a',' ', 'b',' ','c',' ', ' ', ' ', 'd'};
    public static void displayNonWhiteSpaces() {
        for(int i=0; i<a.length; i++) {
            if(a[i] != ' ') {
                System.out.println(a[i]);
            }
        }
    }

    public static void removeWhiteSpaces() {
        int k=0;
        for(int i=0; i<a.length; i++) {
            if(a[i] != ' ') {
                a[k++] = a[i];
                if(k<i) {
                    a[i] = ' ';
                }
            }
        }

        System.out.println("Length " + a.length);

        for(int i=0; i<a.length; i++) {
            System.out.print("\n" + a[i]);
        }

    }

    public static void main(String args[]) {
        displayNonWhiteSpaces();
        removeWhiteSpaces();
    }
}

Statistics basics

Machine learning and Artificial Intelligence is a red hot area these days. I have taken a stats and ML course during my master's program but I badly need a refresher for both. So I signed up for a free course of 'Introduction to Statistics' @ Udacity. It is a great course and I am learning a lot. Here is its link: https://classroom.udacity.com/courses/st101

I am planning to post my notes here. So stay tuned for more details.


Here is my affiliate link for paid Udacity courses. If you buy a course using my link then we both will get $50 credit. 
https://share.udacity.com/x/ZMjrWC

Pricing the product


Product managers are usually require to evaluate costs of multiple options/solutions while building their product. Or they need to decide cost of their product offerings. Either ways below mentioned strategies help to understand the pricing concepts that help with day to day execution.

Strategies to Pricing the product

Cost-Plus Pricing:

  1. Identify the type of product: Online or Physical
  2. Identify the cost of the product: Base price and all the indirect price like marketing, customer acquisition, etc
  3. Once you have a rough idea of the product pricing then price is above the cost price so that you can generate some profit out of it.
  4. Final goal should be: Generate profit from the selling the product or acquire a customer who will buy another product if you sell them this one for free.

Value based pricing:

Identify what value is the product providing to the customer. If it is of high value then high price can be added. For ex: If a meditation app helps someone to avoid a doctor in the long run then you can price it as $7/month or $60/year.

Competitive pricing:

Pricing the product similar to the competitor. If a competitor lowers than price then you should also consider it.
  1. However don’t lower it below your cost price to avoid incurring losses.
  2. Don’t lower it very much as customers will doubt the product quality.

Experimental pricing:

Start with lower price and go higher if the demand is higher. Even while starting with lower price cover your base costs to incur the profit.
  1. If the demand is not high then don’t be afraid to lower your prices.
  2. Find the soft spot where customers are willing to pay for your product without you incurring any losses.

Pricing models

Free, Ad-Supported:

You can launch your app for free. Or put content on websites for free.
  1. You cover the operating costs by running ads on it.
Pros
  1. You don’t need to worry about integrating with payment systems as you are not selling anything on the site/app.
Cons:
  1. Your business pretty much is in hands of ad providers(direct or indirect)
  2. High valued Customers might not like your site due to ads. 
  3. If by mistake inappropriate ads are shown on your site then your app/website loses reputation.

Freemium:

  1. Basic version is free.
  2. Advanced features can be unlocked upon payment.
  3. If there are a lot of basic version users then your operating costs are going to be higher.
  4. You should strive for conversion from free to paid users.

Tiered:

  1. Multiple tiers for different volumes and features. For ex:
    1. $1000/month for upto 10k transactions
    2. $10k/month for upto 1.5M transactions

Subscription:


  1. Charge the user monthly/yearly.
  2. Many online services do this like Netflix charges per month. Amazon charges monthly and yearly.

Free trial: 


Provides users with free trial to attract them into becoming paid customers.

Razor-Blade model: 

Sell a component for a lower price and ensure customers buy add-ons at market or higher price thereby covering the costs.

Design a mobile social app for a chain of local orthodontist offices.

Situation:
  1. Mobile app for patients of local dentists: Yes.
  2. Are these dentists related by chain: No
  3. Is it just one city for now and planning to  expand it later: Yes
  4. Do we need to integrate with insurance providers also so that patients can easy insure that their doctors pays up via insurance. Yes
  5. Ok so we need a mobile app for patients of local dentists to book appointments, look up dentists, their profiles, reviews, hours, integration with insurance providers.


Personas:
  1. Dentists
  2. Patients

Use-Cases:
Patients
  • Create profile, Add insurance, book appointments, pay bills, file claims, write review.
Doctors:
  • Create profile, list accepted insurance, accept insurance, accept payments, file claims, write review for patients.

Solutions:
  1. Profile creation, update, and delete ability for both personas.
  2. Integrate with insurance:
  • Go with a 3rd party integration or integrate with each one of them 1-1.
  • File claims.
  • Process claims.
  1. Integrate with the payments:
  • Ability to pay via CC and Google pay and bank
  • Ability to accept payment via all methods.
  1. Reviews: Both users should be able to write the review.
  2. Where patients can ask questions and other patients/doctors will answer it.

Prioritization:
  1. We’ll use metric based prioritization. Metric is functional app for the user with the convenience of insurance intelligence and payment within it.
  2. So features A, B, C will be part of MVP or version 1.
  3. In version 2, we’ll introduce the features of reviews/Q&A. This will create an ecosystem for the users so they will not leave the app. Moreover, it will be a motivating factor for new users to join the app.

NoSQL

This one is reviewed but I need to delete its copy from hubpages or somewhere NoSQL Data models: key-value  Aggregate model.  key or i...