How does Google achieve a really fast recommendation algorithm with billions of data?

I'm talking about YouTube. There should be hundreds of queries to make a good algorithm like that, but how do your servers respond to that incredibly quickly, considering that there are billions of data to be calculated?