Explain correlation vs. causation with a software example
This tests your critical thinking about data and ability to avoid logical fallacies. A good answer defines both terms, then gives a software example where a third, confounding variable (like traffic) is the true cause of two correlated metrics.
What's really being asked
This question tests your ability to perform rigorous root cause analysis. It's not a statistics quiz; it's about whether you can look at a dashboard with two metrics moving together and correctly identify the underlying driver, rather than jumping to a false conclusion. The interviewer is checking if you can spot and articulate the role of a confounding variable, a core skill for debugging complex systems and interpreting experimental results.
The full answer
First, provide clear definitions: Correlation is a statistical relationship where two variables tend to move together. Causation is a direct, verifiable link where a change in one variable produces a change in another. Second, state the core principle: correlation is a necessary hint for causation, but it is not sufficient proof. Third, and most importantly, introduce the concept of a confounding variable—a hidden third factor that affects both variables and creates the observed correlation. Finally, tie it all together with a plausible software example.
The mistakes people make
Giving a generic, non-software example like "ice cream sales and shark attacks" is a classic red flag. While correct, it fails to demonstrate experience with software systems. Another common mistake is correctly stating that two metrics are correlated but not causal, but then failing to identify the specific confounding variable. For example, saying "CPU and memory are correlated" is weak; saying "they are correlated because of rising user traffic" is strong. Simply defining the terms without any example shows a lack of practical application.
What usually comes next
Expect questions like: "How would you design an experiment to prove causation in your example?" (A/B test, canary release). Or, "What statistical techniques can help suggest causality?" (Granger causality, regression with controls). Or, "Describe another pair of correlated metrics from a system you've worked on and identify the confounding variable."
A concrete example
In our API gateway, we observed that the P99 latency for endpoint A and the number of database connection timeouts were highly correlated, with a coefficient of +0.9. A junior engineer might assume the slow endpoint was causing the database to time out. However, the root cause was a confounding variable: a large client starting a massive data sync every hour. This sync job flooded endpoint A with requests, increasing its latency. Simultaneously, the high volume of requests exhausted the database connection pool, causing timeouts across the entire system, not just for endpoint A. The client's sync job was the cause; high latency and DB timeouts were two separate effects.
Interview question
An engineer observes that API latency and database timeouts are strongly correlated. What is the most rigorous initial conclusion from this data alone?
- a.The high API latency is causing the database to time out.
- b.The correlation is coincidental and the two metrics are functionally unrelated.
- c.A third factor, like a sudden traffic spike, is likely causing both issues independently.Correct
- d.The database timeouts are causing the API latency to increase.
Why? this is the answer
The correct answer identifies a potential confounding variable (a traffic spike) as the root cause, which is a core principle of rigorous analysis. The most tempting distractor is assuming direct causation (A), which is a common logical fallacy that correlation alone does not support.
Just read this? Test yourself on what you have been reading.
Read the original → en.wikipedia.org
- #analytics
- #metrics
- #system design
- #root cause analysis
Put your scrolling time to good use
Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on analytics — each one lists the topics its interview covers.
See open roles