Google Ads works by using a real-time auction system to determine which ads are displayed to a user in response to a search query or other relevant context. When a user submits a search query, Google's ad server receives a request to display ads related to the query. Google then conducts an auction among the advertisers who have placed bids and have ads that are relevant to the search query. The auction takes place in a fraction of a second, with bids and ad quality scores being evaluated in real-time. The ads with the highest combination of bid and quality score will be chosen to appear in the ad space. To ensure that the auction process and ad delivery happen quickly, Google has invested heavily in its infrastructure and technology. This includes using machine learning algorithms to analyze user behavior and predict which ads are most likely to be relevant to a given search query. Overall, Google Ads' ability to deliver the right ad in just 50ms is the result of a complex and sophisticated system that combines auction mechanics, machine learning, and advanced technology infrastructure.