Engineering Decisions · Junior · Question 2 of 12
A search box calls an API billed per request. Results should appear while the user types, but not on every keystroke. What fits?
- 1Throttle: request at most once per second
- 2Debounce: request after a short pause in typing
- 3Search only when the user presses Enter
Show the answer
Correct answer: Debounce: request after a short pause in typing
Explanation
Debounce sends one request once typing pauses, so a burst of keystrokes costs a single call while results still appear without extra action. Throttle fits continuous streams like scroll or resize, where regular updates during the activity matter, but it would bill for half-typed words. Searching on Enter is the cheapest and fits expensive searches, but it breaks the requirement to show results while typing.