MCSD MCSD Performance Optimization and Scalability 2 — Questions and Answers
Question 1: In Azure App Service, which feature allows you to automatically increase or decrease the number of running instances based on CPU or memory metrics?
- Autoscale (Correct answer)
- Deployment slots
- Hybrid connections
- Traffic Manager
Correct answer: Autoscale
Azure App Service Autoscale monitors performance metrics and dynamically adjusts the instance count within defined minimum and maximum boundaries to handle varying load.
Question 2: What is the purpose of the ArrayPool<T> class in .NET when dealing with high-throughput scenarios?
- To rent and return pre-allocated arrays, reducing garbage collection pressure (Correct answer)
- To synchronize array access across multiple threads safely
- To store arrays in Azure Blob Storage for large datasets
- To serialize arrays to JSON without extra allocations
Correct answer: To rent and return pre-allocated arrays, reducing garbage collection pressure
ArrayPool<T> maintains a pool of reusable arrays so hot code paths can rent a buffer, use it, and return it without triggering GC, significantly reducing memory allocation overhead.
Question 3: Which BenchmarkDotNet attribute is required to mark a method for micro-benchmarking in .NET?
- [Benchmark] (Correct answer)
- [Measure]
- [Perf]
- [TimedTest]
Correct answer: [Benchmark]
[Benchmark] tells BenchmarkDotNet to run the decorated method repeatedly in a controlled harness, measuring its mean execution time, memory allocations, and other statistics.
Question 4: What does horizontal scaling (scale out) mean for an Azure-hosted web application compared to vertical scaling (scale up)?
- Adding more VM instances to distribute load, rather than upgrading a single VM to a larger size (Correct answer)
- Partitioning the database into more shards rather than increasing database DTUs
- Increasing thread count within the same process rather than adding worker processes
- Expanding geographic regions rather than adding capacity in one region
Correct answer: Adding more VM instances to distribute load, rather than upgrading a single VM to a larger size
Horizontal scaling adds more identical instances behind a load balancer to spread traffic, offering better fault tolerance, whereas vertical scaling makes one machine more powerful.
Question 5: In Entity Framework Core, what does the Select() projection do to improve query performance compared to loading full entities?
- It retrieves only the specified columns from the database instead of all columns (Correct answer)
- It caches query results in memory to avoid repeated database hits
- It executes the query asynchronously on a background thread
- It splits the query into multiple batches to reduce lock contention
Correct answer: It retrieves only the specified columns from the database instead of all columns
Projecting with Select() generates SQL that fetches only the columns you need, reducing the amount of data transferred from the database and the time spent materializing objects.
Question 6: Which Azure service should you use to distribute global traffic to the nearest application endpoint to reduce latency for US users?
- Azure Front Door or Azure Traffic Manager (Correct answer)
- Azure Load Balancer
- Azure API Management
- Azure Application Gateway
Correct answer: Azure Front Door or Azure Traffic Manager
Azure Front Door and Azure Traffic Manager both route users to the geographically closest healthy endpoint, reducing round-trip time for globally distributed audiences.
In Azure App Service, which feature allows you to automatically increase or decrease the number of running instances based on CPU or memory metrics?