Advanced .NET topics for Enterprise-Grade systems
1. What caching strategies have you used in .NET?
Caching is essential for performance and scalability. I’ve used:
- In-memory caching for fast, local access in web apps.
- Distributed caching (e.g., Redis) for multi-instance environments.
- Output caching for static content in MVC or Razor pages.
services.AddMemoryCache();
var cacheOptions = new MemoryCacheEntryOptions {
AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(10)
};
_cache.Set("ProductList", products, cacheOptions);
Use distributed caching when running across multiple servers or containers.
2. How do you implement sliding vs absolute expiration?
Sliding expiration resets the timer every time the item is accessed. Absolute expiration is fixed—once the time is up, it’s gone.
var options = new MemoryCacheEntryOptions {
SlidingExpiration = TimeSpan.FromMinutes(5),
AbsoluteExpirationRelativeToNow = TimeSpan.FromHours(1)
};
_cache.Set("EmployeeDetails", data, options);
Expiration Type | Behavior |
---|---|
Sliding | Extends lifetime on access |
Absolute | Expires after fixed duration |
Use sliding for frequently accessed data. Use absolute for predictable cleanup.
3. How do you optimize performance in .NET applications?
You measure first, then tune. Here’s what I apply:
- Use
Span<T>
andMemory<T>
to reduce allocations. - Avoid
.Result
and.Wait()
in async code. - Profile with dotTrace, PerfView, or Application Insights.
- Minimize boxing, string concatenation, and GC pressure.
Span<byte> buffer = stackalloc byte[256];
Also: cache expensive computations, batch DB calls, and paginate large datasets.
4. What’s your experience with Sitecore CMS?
Sitecore is powerful but demands discipline. I’ve:
- Built custom components using Sitecore MVC.
- Used personalization and analytics.
- Extended pipelines with custom processors.
- Managed deployments via Helix architecture and Unicorn.
<sitecore>
<pipelines>
<httpRequestBegin>
<processor type="MyNamespace.MyProcessor, MyAssembly"/>
</httpRequestBegin>
</pipelines>
</sitecore>
Sitecore’s config patching and serialization require precision and version control.
5. How do you implement distributed tracing in .NET?
You need visibility across services. I use:
- OpenTelemetry or Application Insights SDK
- Add correlation IDs to logs and headers
- Use
Activity
andDiagnosticSource
for spans
var activity = new Activity("ProcessOrder");
activity.Start();
log.LogInformation($"TraceId: {activity.TraceId}");
activity.Stop();
This lets you trace requests across microservices, queues, and APIs.
6. What are Azure Logic Apps and when should you use them?
Logic Apps are low-code workflows for integrating services. Use them when:
- You need orchestration across APIs, SaaS, and Azure services
- You want visual design and built-in connectors
- You’re automating approvals, emails, or data sync
Example: Blob upload → validate → send email → update database.
They’re great for business automation. For complex branching or high-throughput, use Durable Functions instead.
Top comments (0)