Google Professional Cloud Developer Question 191
Single answerGoogle Cloud PlatformYou are developing a real-time stock trading application that needs to handle high-frequency trade requests and provide low-latency responses. To ensure optimal performance, you decide to implement a caching strategy. Which data access pattern should you prioritize in this scenario?
- A
Read-through caching to ensure always up-to-date data
- B
Write-through caching to ensure cache consistency with the database
- C
Write-behind caching to improve write performance
- D
Cache-aside pattern to control application access to the cache
Show answer and explanation
Correct answer: D
Explanation
In a real-time stock trading application, low-latency responses are critical. The cache-aside pattern is ideal for this scenario as it allows you to retrieve frequently accessed data directly from the cache, reducing latency. The application controls when to update the cache, ensuring optimal performance without unnecessary overhead during reads. Other patterns, while useful in specific cases, do not prioritize low-latency reads in the same way.
- A. Incorrect.
Read-through caching ensures data is always up-to-date by loading data into the cache on a read miss. However, this pattern is not optimal for low-latency scenarios as it introduces additional latency on cache misses.
- B. Incorrect.
Write-through caching ensures data consistency by writing changes to both the cache and database simultaneously. However, it does not prioritize low-latency reads, which is critical in a high-frequency trading application.
- C. Incorrect.
Write-behind caching improves write performance by deferring database writes, but it does not address the need for low-latency reads, which is the primary concern for real-time stock trading.
- D. Correct.
Cache-aside pattern allows the application to directly manage the cache and database access, ensuring low-latency responses by retrieving frequently accessed data from the cache and only querying the database when necessary.