 Hello everyone. We are going to talk about exponential growth. Why the title says fungus on white bread will become clear as we go along and In this session, I'm going to encourage all of you to ask the questions as we go along especially the first three slides We I have about 18 19 slides if we don't get through all of them. I won't be disappointed I won't jump out the nearest window. I'll be just fine So let's go through make sure we nail the first few things and I'll be very thrilled First off, let's try to build an intuition around what is exponential It's essentially a constant doubling time or a constant halving time If you think about it, if it was one in the first unit of time, it becomes two then it becomes four in The next units of time Let's look carefully in the first unit between the zero and the first unit of time. It grew by one unit Between the second between the first and the second unit of time It grew twice as much so the the intuition to build up out here is that your increase the rate of increase Derivative the rate of increase is proportionate to the base Everyone clear so far If you're not clear nod your head from side to side your neighbor won't notice I will Good tops if you need to come back to remind me Actually, let's work through this slide first What is a word of mouth driven model? You have C customers K1 C customers love your product. They love it enough to go and tell the next person. Hey, I love this product Not just like it. Love it. They're the promoters They have F friends who they talk to that's your fan-out ratio and K2 is the susceptibility of the friend who is the listener to Be incented to buy So far clear. So K1 is your promoter F is the fan-out K2 is the susceptibility Now K1 prime is your detractor. They hate your product not just dislike it hate it enough to go and tell someone Never do business with them They hurt me in XYZ ways See customers once again. So K1 and K2 are proportions. C is the base number of customers F is the fan-out and K2 prime is the susceptibility To negative influence So far clear Any questions just raise your hand and Anu will help you and we okay. There's a question there F is the friends that you talk to that's your fan-out So we will get a bit into the nuances of it as we go along anything else Go ahead How come F is same in both cases the assumption in most cases is that F is how social you are so unless there's a Specific product which is liked By more social people and disliked by the lonely people the F will be similar But very good question F may not be same imagine that you have a party product Where the people who like it are the happy outgoing Partying people and the lonely hearts will not like it as much then the F is very different on the two sides But most products F is the same Anything else Isn't there a noise component? Isn't there a noise component? There's always a noise component, but the noise components are typically Gaussian and therefore We hope they will cancel out. This does not account for seasonality. This does not account for peak This is a characterization of the mean and mathematical modeling you take the first order effect But very good point. There is a noise component. What about the passives? What about the passives? Who are neutral to the thing and they don't like or dislike it the passive the passive will buy Or not buy, but they will not be the influencers in the next round Because if you like a product, you don't tell anyone we love it that you like the product But you are not going to be a multiplying factor cool Yes Seasonality is not accounted here as I was mentioning seasonality is a function of the season. This is a function of the base So this is word of mouth modeling How would it go if in the winter season people stay at home? Maybe the effective F during winter is less than the effective F during summer Because summer you're more social. It's not how many friends you believe you have It is how many friends you talk to and in winter if you're snuggled up and not talking to friends This does not hold That's a good point for e-commerce. Maybe winters are better and Winter and summer don't have a strong an effect with the phone and internet So so far clear everyone. Okay now if we solve remember the previous slide where we talked about the rate being proportionate to the base This is the base the rate is completely proportionate to the base This is not approximately exponential. This is not loosely speaking exponential. This has got to be exponential and We'll go into where exponential stops if time permits So if you solve that differential equation You will come with C equals C0 e to the power k1 f k2 minus k1 prime f k2 prime Coming straight out of here Take the C's common. That's your exponent Interesting aside Net promoter score is how many people love your product to talk enough about it Typically off of a survey you look at the eight nine ten and the one through five you say they're detractors They're being polite, but the five sir hate your product actually So if you subtract the eight nine to how many people ranked you eight nine ten How many people ranked you between one and five? That's your net promoter score Many many many people mistakenly believe net promoter score is the exponent. It is not we'll get a bit deeper why My slide's got a bit swapped. Okay. You're back here. Perfect So back with the same equation What if you started a product you believe it should be exponential, but it's not should you be worried? Absolutely Word of mouth is not working if word of mouth works Especially in the inception phase you have to see exponential if time permits will go into what where it stops NPS being zero that factor Exponent factor being zero second thing f being zero f being zero does not necessarily mean you're a lonely person Let's give an example You love your underwear. Do you go and tell your neighbor? I love my underwear. I think you should buy it You don't so effective f for the underwear is zero Effective f for fashionable clothing should be high If you're alone if it's tissue paper for crying and it doesn't bruise the under under part of the eyes You love the product, but you're not going to quite go out and tell people, you know, and you cry next time I highly recommend this box of tissues. So effective f What you're ashamed to share will not so those kind of things society does play a very key part F in the United Kingdom is far less than the effective F in India people talk more Give a lot more advice solicited or unsolicited while in the UK. It's much more stiff upper lip So you don't expect the virality to go quite that strong F in college is far more than F among professionals Why? We become more reserved as we grow up if among women is More than F among men that vice the Verbalizing is far more. So if you've launched a women's beauty product, and you're not seeing exponential You should be extremely worried. Where did I put? Did I put a capital F somewhere? Oh? Maybe just women are more important to me. Let's get back From the word of mouth to the growth of a Facebook or for Square The number of actually this should not be C. That's a typo Okay, fine. C is fine. Say customers of Facebook Think carefully about Facebook. I have two friends. I tell them I'm using Facebook I think you both should subscribe or four friends two of them do So effective effectively K1 is the number of Facebookers who go and tell others F is the number of friends they talk to K2 is the susceptibility People are more susceptible to do what they can do for free So Facebook is free buying a product cost money buying a product like a chewing gum is Inexpensive you can afford it buying a product like a car takes far more validation So once you understand that spectrum you start to see that a lot of things are very different Let's give an example K2 and K2 prime for K2 Imagine that it's a roller coaster one million people tell you I love that roller coaster One person tells you I broke my leg on that roller coaster One million is to one you still won't go the consequence So once you realize K2 prime is far bigger than K2 You start to look at the whole world very differently You do not want the detractors and for a more expensive item you definitely do not want the detractors They'll have a disproportionate influence for a chewing gum. You can afford a detractor for a car. You cannot So Facebook this model is absolutely classic exponential This goes all the way until There it starts to saturate we'll go into the saturation model if time permits So K Facebook is greater than K4 square because of the usefulness but both are exponential Let me go into Twitter. I let up to use a growth team at Twitter at one point. So Twitter is very different It's not about following your friend there so much. It's about following your interests It's about following a celebrity. So when you join unless you're a celebrity People are not going to join because you join so what you have is a step function K time celebrity Barack Obama joins from zero one million Until the next celebrity joins it stays at one million you joining does nothing very little Does that make sense? Any questions at this point I forgot to ask everyone good cool, so Important thing about Twitter is it is usually a step function. You will see a massive massive spike when there's a tsunami or When there's a revolution How does revolution work typically imagine that we want To go to the capital and do something big paint the whole building blue for whatever reason I Tell someone I think we should do it. They if the idea is viral it picks up two more two more How many people at any time are spreading the word of the revolution is? proportionate to the number of revolutionaries That is exponential so in Twitter when there's an revolution you will see a sharp exponent But once the revolution is done revolutions are not evolutions. They decay out of the system. They will decay out too So you will see these sharp ups decay out again some growth with the step functions again decay out Why are celebrities hard to throw on the exponential curve? Part of the exponential growth means that you should be susceptible Celebrities are probably very very secure in general, so it's not that easy We tried some experiments including cases where if one celebrity soccer player in Bundesliga tweets Let the others know hey, he was talking trash about your your football team The other person talks back, but that decays out that doesn't hold up as well So that's the Twitter model is his question was is the reason that they're managed by a social media team not an individual partially, but Partially, it's about Think of it this way Imagine for a second that I wanted a standing ovation in this hall Guess who are the most important people in this hall for that? First row very very good first row because they see no one, but the whole audience sees them That's essentially what's happening with the celebrities Celebrity does something everyone knows and they have a disproportionate influence But celebrities are not that easily influenced. They are doing very well very secure So the first row very good answer I usually bring chocolates for my talk and give out. I'll owe you one. I don't have one today okay So the half-life of a topic depends on your interest in the topic religion and politics are the eternal ones where If you start a storm it has a very long half-life many things don't have quite that half-life Let's look at the fertility of this model or the applicability of this model The key trick once again. I remind you is where the base is proportionate to the rate of change Think about the rabbits in Africa mating and growing the D rabbit over time is Proportionate to the number of rabbits that are there same for the revolutionaries. It's exponential. I Gave this talk at flipkart. It is true at flipkart Same as the flipkart customers and the number of orders you get will be a function of the number of customers times the frequency of a need So if you have books and you buy five books you love buying books and flipkart you would do that on flipkart completely different Fertility of the model every morning you wake up your mouth smells terrible. Don't be ashamed. So does everyone else's the basic point bacteria multiplies it grows exponentially Same for fungus growing on white bread Now I'm going to throw a couple of questions and let's see no chocolates today But you would have deserved a chocolate so you get a virtual chocolate if you do answer so imagine that Say you rinse with listerine rinse it out and Go to sleep next morning your mouth doesn't smell that bad What did you change by rinsing with listerine and rinsing out with water after that? Initial seed value the rate did not change because I rinsed it out with water So it's the mouth after the first I rinse with listerine Then I rinse out with water the mouth after that has no listerine the rate did not change the seed value is Altered and the seed value is lowered and it never really catches up next morning. It's not that bad What if you didn't rinse it out? I rinsed with listerine didn't rinse with water after that Then you've changed the seed value and the rate you've made the environment in your mouth With the presence of listerine far more unfriendly to the bacteria Good so far any questions, okay, very nice Same thing imagine that mosquitoes breed at ground level I tend to wear shorts a lot. I noticed that my legs are bitten far more than my arms What's going on? the mosquitoes Go to the next level with a propensity Which is constant and the next and if you do the math this would come out to be D mosquito dehyde equals minus k height K mosquitoes at that level so if the 15 mosquitoes Maybe two of them go to the next and maybe one of them goes to the next so and if the mosquitoes have no special will when they bump into Your arm, they bite when they bump into your leg They bite then you'll find an exponential distribution of the bites of mosquitoes in your arms and legs Let's imagine infatuation. How does it work? Imagine for a second that you have hundred units of infatuation available That you can give out to anyone You see a stunning hotty and you give away 70 units of infatuation to that one hotty and parents and everything else get the other 30 units Then you see a beautiful dog Wonderful poodle walk down The road you love it. You're going to give it three units of it infatuation or affection How would it work? You would pick out of your hundred units 70 units are reserved for this hotty right now and Then you've 30 units for your parents and everything else and you pick randomly three units and give it to the dog now let's think about the infatuation piece from The hotties infatuation if the hotty had eye units of infatuation Effectively the decay of infatuation is proportionate to the number of units that are available Because the random dog will take away in that proportion. So it's minus Ki So the only difference Between the forgettable beautiful and the unforgettable one is just in the cave any question so far Same thing for sadness Same thing for memory This is flipkart's growth pattern. I actually did much of this math before I joined flipkart And I'm glad to see that it held up because that was a basis of much of my of this massive move that I made Let's think of the consequences of a delay. Why does exponential growth compound into so much crushing pressure? Imagine That you have e to the power KT That's your exponential growth that you get with a launch with a delay KT minus delay If you take e to the power KT constant you get one minus e to the power minus delay Imagine that the delay was two days or constant Essentially what you've got is an exponential growth in the loss that you're seeing this is Without the delay. This is with the delay just like the bacteria In your mouth that multiplies over night. It never catches up So when you have that Many people do not see it that way, but when you have that intuitively it's very different The pressure is very high if you If you integrate the space that's growing exponentially if you're making a little loss that's growing exponentially a One-hour delay if it's every three months doubling Leads to three months two hours six months four hours nine months Eight hours in a year at 16 hours So if you work an hour in those situations in three months doubling time one hour extra today could be two days effectively Let's look at the curse of exponential growth So for a company like Flipkart you're going to have customer support grow exponentially You're going to have the warehouse grow exponentially. You're going to have the procurement grow exponentially You're going to have the logistics grow exponentially, but Logistics is a bit lucky. It gets the second order effect of the density If I go to deliver to you I can deliver to the next-door neighbor pretty much for free servers Computers so this is Flipkart specific the first piece of operations and those who do e-commerce The second part is very universal your databases your or if your orders are growing exponentially guess what so will your databases if The databases are growing exponentially. So are your boxes So so is the probability of the boxes going down so are the number of alerts So are the number of times you'll be woken up at night if you don't do anything We'll talk for a few minutes about the scaling with the database One thing which I find very very useful to look at when I think of a database is People will often the primary thing for an e-commerce company. It's going to be an order The key question is how many reads and how many writes are you going to do to the database in every system? I've seen in my 16 years The come-to-Jesus point is the database you're going to put another mid-tier You're going to do all kinds of things, but that's your come-to-Jesus point and that's where every system will bottleneck What could you do? Oftentimes innocently there two updates going on and a developer puts in a third one Key point mate. You've just reduced the scale of the entire system by 50 percent Stunning one extra call per request because essentially the number of calls came to the database may have been two Times thorders now. It's three times thorders Being very very very careful and pedantic about that will help you the rest of the stuff what you do by enlarge won't matter once Here's another interesting thing to think about your disk most of your disk spin at 5k rpm If you do the math that comes to 12 milliseconds per spin You cannot write faster than that you can write one disk block But if you buffer well, you may be able to at the time the disk comes under your head Chunk down 4k B. So little rights will not help Big chunks will help so buffering as you scale up is a very very key piece to look at Can you buffer things effectively if you're doing the trade-off between reads and writes? Your rights are much simpler to take the whole block just chunk it in throw it over the wall chunk it in in a Big blob you write it to one or two contiguous disc blocks wham 12 milliseconds to seek done Your reads love That the fields are partitioned so that your filters can ask what is the first name? What is the last name? They don't want to go through the whole chunk Makes sense so far everyone Taking I'll take a couple of questions if any Okay, everyone's good. So I forgot what I was trying to say with dictionary. Oh Database dictionary. Yes database dictionary. That's very important So the cost-based optimizer the predicates being pushed down how you organize the predicates are very important And the database dictionary is very key for that decision Allow and enable the database to do that Databases won't last you all the way but make it last as long as you can as a startup Then you can write it when you're bigger Workflows and state transitions It seems very simple to put hundreds of microstates in your workflow where each state writes to the database When it's it'll work After a certain scale, it's two it's hundred times the number of orders. It's too much Look for which microstates are I'd important which microstates is it safe to retry. Let's give you an example of idempotent I tell you to set x equals five if I tell you to set a second time x equals five Nothing gets her x is still equals five So it's safe to retry. I Tell you to increment One to x which was five. I do it once it becomes six I'm not sure whether whether it quite went through. I do it twice. It becomes seven that is non idempotent So if it is idempotent Can you skip through some of the microstates? Reduce the number of states in the state machine zip through allow fewer rights and enable scaling and in case of a failure Just retry the whole thing We talked a bit about buffered rights async rights help you with buffering because otherwise your main thread will be waiting to do things Okay database scaling so You'll do all that good stuff. It'll work for a while then it stops working again. You hit your head again That's your come to Jesus point once again. What are you going to do next? You've partitioned the application with SOA Split it up so that their individual databases for inventory planning procurement warehouse everything and do not Allow cross things to go on. What does it do? Each has a smaller piece of data each is optimized and each gets less traffic What next? Everyone wants to know everything in real time. Sorry after a certain scale that doesn't work. You're going to archive Time window only in OLTP. The rest is chunked out To Hadoop and an OLAP system, which doesn't have to be that latency sensitive You do that then your 45 days doesn't fit into the into the database anymore What are you going to do next? You're going to have to shard and partition the database Some places. It's very simple like our warehouses. I can tell you warehouse one you get a database warehouse two You get a second warehouse three you get a third database. There's not much cross things going on however a Lot of times it's not that simple If they look up so I can hash party hash shard if their domain specific I can range shard but on some key General purpose you have to figure out how to decompose your query You have to figure out parallel execution result assembly. That's essentially what you're going to do. That's non-trivial Three lines three short things, but it's a lot of work if you want you could look at tensing That was done at Google. I worked on that. I was fortunate. So that did a lot of things no sequel Database gives you a lot of generic Help no sequel is fine if you're doing lookup queries very good Especially on those primary keys or if you're doing range queries If you can tolerate staleness, maybe you can do multiple dumps in no sequel and if you can tolerate mild inconsistencies You may be able to get away with updating with eventual consistency or as rapid as you can another thing pre-roll up So if you're going to compute for a month, and it's a lot of things You're going to hundreds of people will ask you for the whole damn day. You might as well pre-roll it up pre-aggregated put it into someplace and deal with it if you can deal with a little Staleness, that's great if you can't then you pre-roll up for all the previous section and Overlay a counter which is in memory for the most recent one. That's your real-time analytics really So on a Google finance everything is pre-rolled up the last bit is changing and oscillating What are the next pieces that will give you a lot of pain one was database? Message bus bound to give you so the messaging on database Everyone does it you will do it and you should do it when you're initial and you're initially starting up That's the simplest thing put a queue on a database you're going to insert into the queue you're going to delete when it dequeues At scale this does not work two problems. You delete. It's fragmenting the database the table gets too big It fragments the heck out of the database and if you look at the characteristics of a message queue your NQ Is an insert? into the database You will select to do something with it and then when you dequeue you delete 33% insert 33% select 33% delete No database in the world is optimized for that use case Every database every single one is optimized for 90 to 95 or 99 percent reads small percentage of rights So this will not scale over time You will try distributed queues once you have distributed queues you have to deal with node failures Where do the messages go you have to deal with recovery you have to deal with split brain You don't want two things triggering and both thinking they're processing the order Otherwise customers get the same message twice. You have to deal with sidelining of messages There are some poison messages where you retry repeatedly and it just consumes the whole cycle you don't want that and Does the system need to be transactional think about it One quick show of hands. I have a lot of material I could either go into more of the mathematical part like we did the initial bit or I could stick a little longer on The queuing messaging and stuff which one do you guys want? Okay? How about this on the mathematical part? How many one show of hands? Okay queuing messaging side Okay, that's a hard one. We'll try okay So cash scaling you're going to try distributed hash tables. You will have to do consistent hashing We won't have time to talk about it. You're going to you're going to look at memory maps What is map to memory? What what are you going to do with the page cash at the OS level? Versus the row cash Page cash is very efficient at the OS level. However, page cash relies heavily on locality Imagine that in that section you are five rows five things in a cache say Items one three and five are very useful, but two or or say one and five are super useful But two three and four are not being queried that much What ends up happening is that that whole block is brought in because it's one page in the OS and Only a small part is very useful. However, it's very very efficient So if there's good locality of data tune your cache so that you get the page cash to work because OS guys do a better job than others in most of this In no sequel we talk about columnar data. We talk about compressed objects Your disk is going to give you blocks your memory your disk processes in milliseconds your memory processes in microseconds Good difference. You may be able to compress Pull in more from disk decompress In memory and go faster than reading on compressed things from disk So the secret of Dremel that Prashant talked about I think yesterday Dremel is L0 77 compressed Very highly compressed and a lot of stuff done in column nerve data column nerve data compresses much better than rows and tuples Why? imagine Ashok Banerjee last name and then you have Salary all kinds of attributes the numbers and strings don't compress as well as say Ashok then Anu Saurav The names compress much better the numbers compress much better together the names and numbers don't quite compress that well and another trick that you use in data warehousing is pre-join and You just pick the columns that you care about Another good trick you have single instruction Typical sequel is very simple instructionally is salary greater than 10,000 Single instruction that has to be done on billions of rows. It's a classic single instruction multiple data Concept you may be able if you're writing a custom piece may be able to do things with vector processing Maybe with game processors. They're not just for games. They can do real things so single instruction multiple data the data is jittered completely completely down compiled and really good and It's cashed at the CPU layer. It's really good And if you pull in a chunk which matches up with your CPU run length or cash link your performance screens Skip I will try in this last one. You will not get it completely. When does exponential growth end? This comes from disease modeling There's a disease disease W. Whatever it is. I got this out of model thinking class on Coursera Say wobblies. There's a disease wobblies You have W by N people infected with the disease and minus W by N people who are not infected with the disease and recovery rate are recovery rate acting on W by N people There's a C contact rate say the disease is spread by handshake or kiss or something. So some contact K is the transmission rate if you do the math the ends would be moved here if you take W by N common This piece in the early phase This is very key this piece in the early phase where W is very little comes close to one That is the reason why in the early phase you get exponential W is much smaller than N and Minus W is almost equal to N. This is close to one. So it effectively comes to W by N CK minus R So in the early phase you will get a classic exponential then when this no longer holds true This will s out Because initially you'll have so in an e-commerce setup Imagine that flip cart was a disease that people buy and the getting well was you get out of it? So get in in that case the disease spreads by me telling you hey you should buy because I loved it it spreads susceptibility the whole equation works and Eventually it stops because I'm most of the people are already in the same disease Disease is not a great analogy, but it shows the purpose this comes from epidemiology and This also helps you figure out what you would do with vaccination if you wanted to immunize a market to a competitor what you would effectively do is This factor CK minus R is called the reproductive rate of a disease measles mumps. These are very high So that's the virality of this If you have vaccine V if you do the math It's greater than zero then it grows if it's less than zero you don't have to worry It will simmer out CK bar are greater than one if you have one minus V. That's your vaccination Effective population decreases if half of you are vaccinated then the meetings happen But that half the back half of the room will never get infected For a competitor if you can vaccinate which is if you grow beyond a tipping point It's very hard for a competitor to get in that is the reason why they're gorilla markets You won't fully get it in two minutes, but it's okay All right, I will end with a little music which is Good From Facebook the flip car From the bacteria in your mouth to the fungus growing on white bread from the number of shorts in your day to day To the change the action of an atom bomb From the decay of Your infatuation to the decay of your memory To the decay of your sadness to the decay of mosquitoes with height and the decay of allergens with height It's all decay exponentially. I'll leave you With a little bit Just six more words Once you see the world for what it is optimize Analyze Criticize Realize Visualize all around Thank you. I'll take this