By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
Performance measures how efficiently a system (software, hardware, or process) completes tasks under real-world conditions. Businesses use it to ensure applications run fast, scale smoothly, and deliver value without waste—whether it’s a website handling 10,000 users, a database processing transactions, or a supply chain optimizing delivery routes.
Poor performance costs money, frustrates users, and loses opportunities. A 1-second delay in page load can drop conversions by 7%. A slow API can bottleneck an entire workflow. Performance isn’t just a technical concern—it’s a competitive advantage. Companies like Amazon, Netflix, and Uber invest heavily in performance engineering because it directly impacts revenue, customer retention, and operational costs.
A bottleneck is the slowest part of a system that limits overall performance. Common culprits: - CPU: Heavy computations (e.g., image processing, encryption).- Memory: Too little RAM forces swapping to disk (100x slower).- Disk I/O: Databases or logs writing to slow storage.- Network: High latency or low bandwidth between services.- Code: Inefficient algorithms (e.g., O(n²) sorting on large datasets).
Storing frequently accessed data in fast storage (e.g., RAM) to avoid repeated expensive operations.- Examples: - CDNs caching static assets (images, CSS). - Databases caching query results (Redis, Memcached). - Browsers caching API responses.- Trade-off: Stale data vs. speed. Cache invalidation is hard.
Performance optimization follows a cycle:
Use ab (Apache Benchmark) to test a web server’s throughput and latency:
ab
ab -n 1000 -c 100 http://your-website.com/
-n 1000
-c 100
Profile a slow Python script with cProfile:
cProfile
import cProfile def slow_function(): total = 0 for i in range(10_000_000): total += i return total cProfile.run("slow_function()")
Cache a slow API call in Python using functools.lru_cache:
functools.lru_cache
from functools import lru_cache import time @lru_cache(maxsize=100) def slow_api_call(user_id): time.sleep(2) # Simulate slow API return f"Data for {user_id}" # First call: slow (2s) print(slow_api_call(1)) # Second call: fast (cached) print(slow_api_call(1))
WHERE
JOIN
ORDER BY
A database query takes 500ms to execute. Which optimization is most likely to reduce latency? A) Adding more CPU cores to the database server.B) Creating an index on the queried column.C) Increasing the database’s RAM.D) Moving the database to a faster SSD.
Correct Answer: B) Creating an index on the queried column.Explanation: Indexes speed up queries by reducing full table scans. CPU, RAM, and SSDs help but don’t address the root cause (inefficient queries).Why the Distractors Are Tempting: - A) More CPU helps parallelism but not single-query latency.- C) RAM helps caching but not query execution time.- D) SSDs improve I/O but not query planning.
Your web app’s API response time spikes during peak hours. Which approach is the most scalable? A) Upgrading the server to a more powerful machine.B) Implementing a rate limiter to reject excess requests.C) Adding a load balancer and horizontal scaling.D) Caching all API responses for 24 hours.
Correct Answer: C) Adding a load balancer and horizontal scaling.Explanation: Horizontal scaling distributes load across multiple machines, handling more users without performance degradation.Why the Distractors Are Tempting: - A) Vertical scaling is limited by hardware.- B) Rate limiting degrades user experience.- D) Caching all responses risks stale data.
A Python script processes a large CSV file line by line. It’s slow. What’s the most effective optimization? A) Using multithreading to process lines in parallel.B) Reading the entire file into memory at once.C) Rewriting the script in C++.D) Using a generator to process lines lazily.
Correct Answer: D) Using a generator to process lines lazily.Explanation: Generators avoid loading the entire file into memory, reducing I/O and memory usage.Why the Distractors Are Tempting: - A) Python’s GIL limits multithreading for CPU-bound tasks.- B) Reading the entire file into memory is slow and memory-intensive.- C) Rewriting in C++ helps but isn’t the simplest fix.
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.