📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

📚 Interview question

How would you run a .NET 10 workload on AWS? Explain Lambda and its .NET runtime (cold starts, Native AOT, SnapStart), ECS on Fargate versus EKS for containerised APIs, and what RDS for SQL Server gives you and costs you. When would you choose each?

Covers .NET 10 on AWS Lambda (managed dotnet10 runtime, cold starts, Native AOT, SnapStart, ASP.NET Core hosting), ECS on Fargate versus EKS for containers, and RDS for SQL Server (licensing, Multi-AZ, limits), with when to choose each.

Intermediate Theory Intermediate aws aws-lambda devops dotnet ecs-fargate rds

🎯 Key points

  • Lambda: managed dotnet10 runtime (announced 8 January 2026), 15-minute limit, memory up to 10,240 MB, pay per request and GB-second
  • Cold starts: Native AOT on a custom runtime or SnapStart cut them; JIT cold starts often hundreds of ms to over a second
  • Amazon.Lambda.AspNetCoreServer.Hosting runs an existing Minimal API behind API Gateway or a function URL
  • ECS on Fargate: no nodes to manage, task definitions, a public ALB for internet traffic or Service Connect / internal ALB between services; small chiseled images start tasks faster
  • EKS: managed Kubernetes control plane plus upgrades, add-ons and node management you own; pick it for portability or an existing platform team
  • RDS for SQL Server: licence-included or BYOL, Multi-AZ for HA, automated backups; Standard edition unless you need Enterprise-only features
  • Watch both with CloudWatch: Lambda Duration, Init Duration, Throttles and ConcurrentExecutions; ECS CPU, memory and ALB TargetResponseTime
  • Choose by workload shape: spiky event-driven work on Lambda, steady APIs on Fargate, Kubernetes only when you need it

⏱ 30-second answer

On AWS I'd pick the compute by workload shape. Lambda has a managed dotnet10 runtime; it suits spiky, event-driven work (SQS, S3 events, schedules) and can host a whole Minimal API with Amazon.Lambda.AspNetCoreServer.Hosting. Its costs are cold starts, which Native AOT or SnapStart reduce, and a 15-minute limit.

For a steady containerised API, ECS on Fargate is the default: no nodes, an ALB in front, task roles for identity. EKS is managed Kubernetes; I'd only choose it when we need Kubernetes portability or already run a platform team.

For the database, RDS for SQL Server keeps EF Core and T-SQL unchanged, with Multi-AZ and automated backups, but licence-included SQL Server is expensive and you lose sysadmin. The trade-off is ops effort against control and cost at steady load.

🗣 Full answer (senior)

How I would answer this in an interview

"I'd start from the shape of the workload. For event-driven or spiky work, like processing SQS messages, reacting to S3 uploads or running scheduled jobs, I'd use Lambda. AWS added a managed dotnet10 runtime in January 2026, so I can deploy .NET 10 functions directly, or ship a container image. A function runs for at most 15 minutes and can have up to about 10 GB of memory, and CPU scales with memory. The cost to manage is the cold start: a JIT-compiled .NET function with the AWS SDK and DI can take several hundred milliseconds to over a second to start. I reduce that with Native AOT on a custom runtime, SnapStart, which restores a snapshot of an initialised function, trimming dependencies, or provisioned concurrency when latency really matters.

For a steady HTTP API, I'd containerise it and run it on ECS with Fargate. There are no nodes to patch; I define a task definition with CPU, memory and an IAM task role, put an Application Load Balancer in front, and let ECS service auto scaling add tasks on CPU or request count. EKS gives me managed Kubernetes, which is worth it if the organisation already has a platform team, Helm charts and GitOps, or needs portability across clouds. Otherwise it's a lot of operational surface for one team.

For data, RDS for SQL Server means EF Core migrations and our T-SQL work unchanged. I get automated backups, point-in-time restore and Multi-AZ failover. What I give up is sysadmin, some instance-level features, and money: licence-included Enterprise edition, Multi-AZ, is one of the most expensive lines on an AWS bill. The mistake I see is putting a latency-sensitive, always-busy API on Lambda because 'serverless is cheaper'. Above steady load, Fargate is usually both cheaper and faster."


Compute options for .NET on AWS

Option What you manage Scaling Best for Not for
Lambda (dotnet10) Code and config Per request, to zero Events, queues, schedules, spiky APIs Long jobs (>15 min), steady high load, WebSockets with state
App Runner Container image Requests, to minimum 1 Small web apps, low ops Complex networking, fine-grained scaling
ECS on Fargate Task definitions, ALB Service auto scaling Containerised APIs and workers Teams standardised on Kubernetes
ECS on EC2 Plus the instances Capacity providers Cost-optimised steady load, GPUs Teams without ops capacity
EKS Kubernetes manifests, add-ons, nodes (or Fargate / Auto Mode) HPA, Karpenter Platform teams, multi-cloud portability One small team, one service

Lambda cold start options

Technique Effect Cost
Native AOT (custom runtime provided.al2023) Largest cold start reduction Trimming and reflection limits; build on Linux
SnapStart Restores from a snapshot after init Must handle uniqueness (random seeds, connections) after restore
Provisioned concurrency Pre-warmed instances You pay while idle
Higher memory More CPU, faster init Higher GB-second price
Fewer dependencies, lazy init Less work at start-up Code discipline

RDS for SQL Server: what you get and give up

You get You give up
Automated backups, point-in-time restore sysadmin, OS access
Multi-AZ synchronous standby, automatic failover Some features (for example certain instance-level configuration)
Patching windows Licence cost: licence-included pricing per vCPU-hour
Same EF Core provider and T-SQL Scaling storage and instance size causes brief disruption

Production example

A team ran an invoice-generation API on Lambda with JIT: p99 latency was [2.1 s] on cold starts at 9 am. Moving the request path to ECS on Fargate with 2–6 tasks gave a steady p99 of [180 ms] and cost [30%] less at their volume, while the nightly PDF batch stayed on Lambda triggered by SQS, where cold starts did not matter.

🔍 What the interviewer is checking

Checks whether the candidate can match .NET workloads to AWS compute and data services on latency, duration, cost and operational effort.

Green flags

  • Knows the managed .NET 10 Lambda runtime and the cold start mitigations (Native AOT, SnapStart, provisioned concurrency)
  • Defaults to ECS on Fargate for steady APIs and explains task roles and the ALB
  • Treats EKS as a platform decision
  • Knows RDS Multi-AZ failover needs retry logic and that licensing drives cost

Red flags

  • "Serverless is always cheaper"
  • Doesn't know Lambda's 15-minute limit or concurrency model
  • Thinks Aurora runs SQL Server

📚 Learn in depth

1. How Lambda runs .NET

Invoke ─▶ Lambda service ─▶ execution environment (Firecracker microVM)
                              ├─ INIT: start runtime, load assemblies, run constructor / DI
                              ├─ INVOKE: call handler(event, context)
                              └─ stays warm for later invokes, then frozen / recycled

A cold start is the INIT phase: starting the .NET runtime, JIT-compiling start-up code, building the DI container and creating SDK clients. A warm environment skips it. One environment handles one request at a time, so concurrency equals the number of environments.

With the managed dotnet10 runtime you deploy a zip with dotnet lambda deploy-function (Amazon.Lambda.Tools). With a custom runtime (provided.al2023) you ship a Native AOT binary and use Amazon.Lambda.RuntimeSupport to poll the Runtime API yourself; there is no JIT, so start-up is much faster, but reflection-heavy libraries need trimming-safe alternatives (source-generated System.Text.Json).

SnapStart runs INIT once at publish time, snapshots the memory, and restores from it. Anything that must be unique per environment (random seeds, cached credentials with expiry, open connections) must be re-created after restore using runtime hooks.

2. Hosting ASP.NET Core in Lambda

Amazon.Lambda.AspNetCoreServer.Hosting adds builder.Services.AddAWSLambdaHosting(LambdaEventSource.HttpApi). It translates API Gateway or function URL events into HttpContext, so the same Minimal API runs locally with Kestrel and in Lambda. It is convenient, but every cold start builds the whole ASP.NET Core pipeline.

3. ECS on Fargate

Route 53 ─▶ ALB (HTTPS, target group health checks)
              └─▶ ECS service (desired count 2..10)
                    └─ tasks on Fargate: container image from ECR
                         task role  ─▶ S3, SQS, Secrets Manager
                         execution role ─▶ pull image, write logs

Key pieces: the task definition (image, CPU and memory, env vars, secrets from Secrets Manager, log driver), the task role used by your code, and the execution role used by ECS itself. Rolling deployments replace tasks behind the ALB; CodeDeploy can do blue-green.

For .NET in a container, remember that the GC sees the container's memory limit; set DOTNET_GCHeapHardLimitPercent if you need headroom for native memory.

4. EKS

AWS runs the control plane; you run nodes (managed node groups, Karpenter, Fargate profiles or EKS Auto Mode). You add the AWS Load Balancer Controller for ingress and EKS Pod Identity (or IRSA) so pods get IAM roles. It is powerful and portable, and it is a platform you have to own: upgrades every Kubernetes minor release, add-on versions, cluster security.

5. RDS for SQL Server

RDS runs SQL Server on managed instances. Multi-AZ keeps a synchronous standby in another Availability Zone and fails over by switching DNS, usually within one to two minutes, so your .NET connection must retry (EnableRetryOnFailure in EF Core). Backups give point-in-time restore within the retention period. Licence-included pricing bundles the SQL Server licence per vCPU-hour; Standard edition is much cheaper than Enterprise and is enough for most line-of-business apps.

6. Choosing

  • Requests are rare or bursty, work is short: Lambda.
  • Steady HTTP traffic, long-lived connections, background workers: ECS on Fargate.
  • Many services, platform team, Kubernetes tooling already in place: EKS.
  • Existing SQL Server schema and T-SQL: RDS for SQL Server; greenfield and cost-sensitive: consider Aurora PostgreSQL with the Npgsql EF Core provider.

Try it yourself

  1. Deploy a hello-world .NET 10 Lambda with dotnet lambda deploy-function --function-runtime dotnet10 and note the Init Duration in its CloudWatch log REPORT line.
  2. Rebuild it with Native AOT on provided.al2023 and compare the init duration.
  3. Run a Minimal API locally, then in Lambda with AddAWSLambdaHosting, and compare cold and warm latency.
  4. Push a .NET 10 image to ECR and run it as an ECS Fargate service behind an ALB with two tasks.
  5. Create a small RDS for SQL Server Express instance, run EF Core migrations against it, then reboot it with failover (on a Multi-AZ instance) and watch your app's retry logs.

💻 Code

The same Minimal API runs on Kestrel locally and in Lambda; a separate SQS-triggered function handles background work.

// Api/Program.cs: Minimal API that can run in Lambda behind an HTTP API, or anywhere with Kestrel.
using Microsoft.EntityFrameworkCore;

var builder = WebApplication.CreateBuilder(args);

// Only active when running inside Lambda; locally Kestrel serves requests as usual.
builder.Services.AddAWSLambdaHosting(LambdaEventSource.HttpApi);

builder.Services.AddDbContext<OrdersDb>(o => o.UseSqlServer(
    builder.Configuration.GetConnectionString("Orders"),
    sql => sql.EnableRetryOnFailure())); // RDS Multi-AZ failover switches DNS; retry transient errors

var app = builder.Build();

app.MapGet("/orders/{id:int}", async (int id, OrdersDb db, CancellationToken ct) =>
    await db.Orders.AsNoTracking().FirstOrDefaultAsync(o => o.Id == id, ct) is { } order
        ? Results.Ok(order)
        : Results.NotFound());

app.Run();

public sealed record Order(int Id, string Customer, decimal Total);

public sealed class OrdersDb(DbContextOptions<OrdersDb> options) : DbContext(options)
{
    public DbSet<Order> Orders => Set<Order>();
}
// Worker/Function.cs: SQS-triggered Lambda with partial batch failure reporting.
using Amazon.Lambda.Core;
using Amazon.Lambda.SQSEvents;

[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))]

namespace Worker;

public sealed class Function
{
    // Built once per execution environment (during INIT), reused while warm.
    private static readonly HttpClient Http = new();

    public async Task<SQSBatchResponse> Handler(SQSEvent evt, ILambdaContext context)
    {
        var failures = new List<SQSBatchResponse.BatchItemFailure>();
        foreach (var message in evt.Records)
        {
            try
            {
                await ProcessAsync(message.Body);
            }
            catch (Exception ex)
            {
                context.Logger.LogError($"Message {message.MessageId} failed: {ex.Message}");
                // Only this message returns to the queue; the rest of the batch is deleted.
                failures.Add(new() { ItemIdentifier = message.MessageId });
            }
        }
        return new SQSBatchResponse(failures);
    }

    private static Task ProcessAsync(string body) => Task.CompletedTask; // idempotent work goes here
}
# Deploy the worker on the managed .NET 10 runtime, on Arm (Graviton) for lower cost.
dotnet lambda deploy-function OrdersWorker \
  --function-runtime dotnet10 \
  --function-architecture arm64 \
  --function-memory-size 1024 \
  --function-role orders-worker-role

⚠ Common mistakes

  • Mistake: Running a busy, latency-sensitive API on Lambda with the JIT runtime and no mitigation. Why it is wrong: Every scale-out adds cold starts, and at steady load you pay more than for containers. Instead: Use ECS on Fargate for steady APIs, or Native AOT, SnapStart or provisioned concurrency if Lambda is required.
  • Mistake: Creating SDK clients and HttpClient inside the handler. Why it is wrong: Each invocation pays the creation cost and can exhaust sockets. Instead: Create them once in a static field or the constructor so they are reused while the environment is warm.
  • Mistake: Failing the whole SQS batch when one message fails. Why it is wrong: Successful messages are redelivered and processed again. Instead: Enable ReportBatchItemFailures and return SQSBatchResponse with only the failed message ids.
  • Mistake: Putting a public ALB in front of every ECS service. Why it is wrong: Internal services become reachable from outside and you pay for load balancers you don't need. Instead: Use a public ALB only for internet-facing APIs, and ECS Service Connect or an internal ALB for service-to-service calls.
  • Mistake: Shipping a 1 GB SDK-based image to Fargate. Why it is wrong: Fargate pulls the image for every new task, so large images slow scale-out and deployments. Instead: Use a multi-stage build with the aspnet chiseled runtime image (or Native AOT) and keep the image in ECR in the same region.
  • Mistake: Choosing EKS for a single team's two services "for the future". Why it is wrong: The team then owns Kubernetes minor-version upgrades several times a year, add-on compatibility, node patching and cluster security, while the services gain nothing ECS couldn't give them. Instead: Start with ECS on Fargate; move to EKS when there is a platform team and a real need such as multi-cloud portability.
  • Mistake: Using Enterprise edition on RDS by default. Why it is wrong: Licence-included Enterprise costs several times Standard. Instead: Choose Standard for typical line-of-business apps; choose Enterprise only for features you actually use, such as online index rebuilds at scale, more than Standard's memory and core limits, or readable secondaries for reporting.
  • Mistake: No retry on database connections with Multi-AZ. Why it is wrong: Failover changes DNS and drops connections for a minute or two. Instead: Use EnableRetryOnFailure and keep connection timeouts short.
  • Mistake: Not alarming on Lambda Throttles or ECS memory. Why it is wrong: Account concurrency limits and OOM-killed tasks fail silently from the user's view. Instead: Set CloudWatch alarms on Throttles, Errors, ConcurrentExecutions, ECS MemoryUtilization and ALB 5xx counts.

🏛 Senior insight: trade-offs

The senior answer is a decision, not a catalogue: pick the least operationally heavy option that meets the workload's latency, duration and cost needs. Lambda wins on bursty, short work and loses on steady high load and strict p99. Fargate is the sensible default for a containerised .NET API. EKS is an organisational choice about owning a platform. RDS for SQL Server is a migration enabler; the long-term cost question is whether you stay on SQL Server at all.

Measure it: compare cost per million requests and p99 for both Lambda and Fargate at your real traffic profile, and read Init Duration in Lambda REPORT logs before arguing about cold starts.

Option When it fits Cost profile When not to
Lambda Event-driven, spiky, short Pay per use; zero when idle Steady load, >15 min, strict p99 without AOT
ECS on Fargate Steady APIs and workers Per vCPU and GB-hour Very bursty work idle most of the day
EKS Platform team, many services Control plane fee plus nodes plus people Small teams
RDS for SQL Server Existing SQL Server estate Licence-included per vCPU-hour Greenfield where PostgreSQL would do

🔗 Follow-ups the interviewer may ask

  1. When: Candidate compares Lambda, Fargate and EKS Why: Checks that they reason the same way on Azure (Functions, Container Apps, AKS).
    How to answer

    I choose by how much platform the team wants to run:

    • App Service: one or a few web apps, always on, deployment slots, almost no ops. Paid per plan instance.
    • Azure Functions: event-driven or spiky work (queues, timers, blobs); Flex Consumption scales per event and to zero.
    • Container Apps: containerised microservices on managed Kubernetes with KEDA scaling, revisions and scale to zero, without touching the cluster.
    • AKS: full Kubernetes when you need its API, custom networking or many services and have a platform team.

    The trade-off is control versus operations: each step towards AKS gives more control and more work. I start with the simplest option that meets the requirements and move only when I hit a concrete limit.

  2. When: Candidate talks about cold starts and serverless hosting plans Why: Checks depth on the Azure Functions side: isolated worker, Flex Consumption, Durable Functions.
    How to answer

    Azure Functions runs small pieces of code in response to triggers (HTTP, Service Bus, Blob, Timer, Event Grid). For .NET 10 you use the isolated worker model: your code runs in its own process with a normal Program.cs, DI and middleware, and talks to the Functions host over gRPC. The in-process model reached end of support in November 2026.

    • Hosting: Flex Consumption (scale to zero, VNet, always-ready instances), Premium (pre-warmed, no cold start), or Dedicated (App Service plan).
    • Cold starts come from starting a new instance; reduce them with always-ready instances and lean startup.
    • Durable Functions handles long-running, stateful workflows through replayed orchestrations.

    The trade-off: very little infrastructure work and per-event scaling, in exchange for the platform's execution limits and an at-least-once programming model.

  3. When: Candidate mentions cold starts as Lambda's main drawback Why: Checks whether they can measure and fix cold starts rather than just name them.
    How to answer

    First I measure: the Init Duration in the CloudWatch REPORT lines (or Lambda Insights), and a trace of the INIT phase to see where time goes: runtime start, assembly loading, DI, SDK clients, secrets fetched at start-up, and VPC networking if the function is attached to a VPC. Then I try the cheapest fixes first:

    1. Remove unused dependencies and lazy-load rarely used services.
    2. Move secret reads to a cached client.
    3. Raise memory, which gives more CPU during init.
    4. Switch to source-generated System.Text.Json.
    5. Try SnapStart.

    Scheduled warm-up pings (an EventBridge rule every few minutes) keep only one environment warm, so they don't help when traffic scales out. If p99 still matters, I publish with Native AOT on provided.al2023, or pay for provisioned concurrency for the latency-critical function only. I re-measure after each change.

More in AWS

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me