Ravindra BagaleCourses & study guides Track your progress

AWS Cloud

Hosting Node.js, Python, Java, PHP and .NET Websites on AWS: Interview Questions and Answers (50 Questions)

This page has 50 interview questions on one practical skill: putting a real website or API, written in any language, onto AWS and keeping it running. These questions come up in DevOps, cloud support and full stack interviews.

1. An everyday example: opening a restaurant

Why do interviewers ask this?

Writing code is only half the job. The other half is running it for real users: the right server, the right port, HTTPS, a domain name, logs, scaling and quick fixes when a deploy breaks. Interviewers want to know you have done this, not only read about it.

Think of opening a restaurant. The recipe is your code (Node.js, Python, Java, PHP, .NET, Go or Ruby). The kitchen is the compute (EC2, Elastic Beanstalk, ECS on Fargate or Lambda). The waiter at the door is the reverse proxy or load balancer (Nginx or an ALB). The address on Google Maps is the domain (Route 53). The hygiene certificate on the wall is HTTPS (ACM). The kitchen cameras are logs and metrics (CloudWatch).

How to use this page

  • Know one full path well, for example a Node.js API in a container on ECS Fargate behind an ALB with Route 53 and ACM.
  • For each language, know how the app starts, which port it listens on, and where its logs go.
  • For senior questions, describe what you check first when a deploy fails.

2. Fresher level questions

Start here if you are a fresher or have less than two years of experience. Try to answer each question aloud first. Then open it and compare.

Q1. How do you host a static HTML, React or Angular site on AWS? Fresher

Why: a static site has no server code, so you do not need a server. This is cheap and very fast.

How:

  • Build the site. For React, npm run build creates a build or dist folder.
  • Upload the files to a private S3 bucket.
  • Create a CloudFront distribution with the bucket as origin, using Origin Access Control (OAC) so only CloudFront can read the bucket.
  • Add a free ACM certificate and your domain in Route 53.
aws s3 sync ./dist s3://shop-web-prod --delete

Output:

upload: dist/index.html to s3://shop-web-prod/index.html

The new files are in S3. --delete removes old files that are no longer in the build.

Q2. Why does a React or Angular single-page app show 403 or 404 when you refresh a page like /orders on CloudFront? Fresher

The browser asks CloudFront for /orders. There is no file called orders in S3, so S3 returns 403 (private bucket) or 404.

The app's router only works after index.html is loaded.

Fix: make CloudFront return /index.html for these paths:

  • Add custom error responses for 403 and 404 that return /index.html with status 200.
  • Or use a CloudFront Function that rewrites paths without a file extension to /index.html. This is cleaner because real missing files can still return 404.
Q3. What is AWS Amplify Hosting? Fresher

Amplify Hosting is a managed service that builds and hosts web apps from a Git repository.

You connect a branch, and on every push Amplify builds the app, deploys it to a global CDN and gives you a URL. It supports static sites and server-side rendered apps for frameworks such as Next.js.

Useful features: preview environments for pull requests, custom domains with free HTTPS, environment variables and password-protected branches.

Everyday example: a front-end team that does not want to manage S3 and CloudFront settings uses Amplify for the marketing site.

Q4. What are the main ways to run a Node.js, Python or Java backend on AWS? Fresher
  • EC2: a virtual server. You install the runtime, run the app and manage everything. Full control.
  • Elastic Beanstalk: you upload code, and it creates EC2, load balancer, scaling and monitoring for you.
  • ECS on Fargate: you package the app as a container. AWS runs it without servers to manage.
  • Lambda: you upload functions. They run on requests and you pay per use.
  • App Runner: a simple container service, but it is closed to new customers since 30 April 2026.

Choose by team skills, traffic pattern and how much control you need.

Q5. Why do apps usually run on a port like 3000 or 8080 behind Nginx instead of port 80 directly? Fresher
  • On Linux, ports below 1024 need root rights. Running the app as root is a security risk.
  • Nginx is very good at handling many client connections, HTTPS, compression and static files.
  • Nginx can restart, buffer and route requests while the app restarts.

So the app runs as a normal user on an internal port, such as 3000 for Node.js or 8000 for Gunicorn, and Nginx listens on 80 and 443 and forwards requests to it.

Everyday example: a receptionist (Nginx) greets every visitor and sends them to the right office (the app).

Q6. What is a reverse proxy, and what does a basic Nginx config for an app look like? Fresher

A reverse proxy receives requests from users and forwards them to the app server behind it.

cat /etc/nginx/conf.d/shop.conf

Output:

server {
  listen 80;
  server_name shop.example.com;
  location / {
    proxy_pass http://127.0.0.1:3000;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
  }
}

Nginx listens on port 80 and sends every request to the app on port 3000. The headers pass the real host, client IP and protocol to the app.

Q7. How do you add HTTPS to a website hosted on AWS? Fresher

Common ways:

  • Put an ALB or CloudFront in front and attach a free public certificate from AWS Certificate Manager (ACM). ACM renews it automatically when DNS validation stays in place.
  • For CloudFront, the ACM certificate must be in us-east-1. For an ALB, it must be in the same Region as the ALB.
  • For a single EC2 server without a load balancer, use a certificate such as one from Let's Encrypt with Certbot in Nginx.

Then redirect HTTP to HTTPS, so users never stay on plain HTTP.

Q8. How do you point a domain to a website on AWS using Route 53? Fresher
  • Create a hosted zone for the domain and set the registrar's name servers to the Route 53 name servers.
  • For the root domain (example.com), create an alias A record to the ALB, CloudFront distribution or S3 website endpoint. A CNAME is not allowed at the root.
  • For www, create another alias, or a CNAME to the same target.
  • Add AAAA alias records if you use IPv6 with CloudFront or a dual-stack ALB.

Alias records to AWS targets have no query charge and follow the target's IP changes automatically.

Q9. What is an environment variable and why should apps read configuration from it? Fresher

An environment variable is a named value given to a process when it starts, such as DB_HOST or NODE_ENV.

Why: the same code or container image can run in dev, test and prod with different settings. Nothing environment-specific is hard-coded.

Examples:

  • Node.js reads process.env.DB_HOST.
  • Python reads os.environ["DB_HOST"].
  • Spring Boot maps SPRING_DATASOURCE_URL to spring.datasource.url.

Do not put real secrets into plain environment variables in source code. Load them from Secrets Manager or Parameter Store at deploy time or start time.

Q10. What is a health check endpoint and what should it return? Fresher

A health check endpoint is a URL, such as /health, that a load balancer or orchestrator calls often to see if the app is working.

It should:

  • Return HTTP 200 quickly (well under the health check timeout) when the app can serve requests.
  • Return an error code when the app is broken, for example it cannot reach a critical dependency.
  • Not do heavy work, and not need a login.

Example: the ALB target group checks /health every 15 seconds. If a task fails several checks in a row, it gets no traffic and ECS replaces it.

Q11. What is AWS Elastic Beanstalk? Fresher

Elastic Beanstalk is a service where you upload your application code, and it creates and manages the environment for it: EC2 instances, an optional load balancer, Auto Scaling, health monitoring and logs.

You still own the resources and can see them in your account.

Current platforms include Node.js, Python, Java SE, Tomcat, PHP, .NET on Windows Server, .NET Core on Linux, Go, Ruby and Docker.

Everyday example: you give your recipe to a catering company. They bring the kitchen, staff and plates. You can still check how they work.

Q12. How do you keep a Node.js app running on an EC2 server after you log out? Fresher

If you start it with node app.js in a terminal, it stops when the session ends or the app crashes.

Use a process manager:

  • systemd: create a service unit with Restart=always. It starts on boot and restarts after crashes.
  • Or PM2, a Node.js process manager that can also run several copies.
sudo systemctl status shop-api --no-pager | head -3

Output:

● shop-api.service - Shop Node.js API
     Loaded: loaded (/etc/systemd/system/shop-api.service; enabled)
     Active: active (running) since Fri 2026-11-20 09:12:04 IST; 2h ago

The app runs as a service, starts at boot (enabled) and has been running for two hours.

Q13. How is a Python web app like Django or Flask served in production? Fresher

The built-in development server (manage.py runserver or flask run) is not for production.

In production:

  • A WSGI server such as Gunicorn runs the Django or Flask app with several worker processes.
  • For async frameworks like FastAPI, an ASGI server such as Uvicorn is used, often managed by Gunicorn with Uvicorn workers.
  • Nginx sits in front for HTTPS, static files and buffering.

Example: gunicorn shop.wsgi:application --workers 3 --bind 127.0.0.1:8000.

On Elastic Beanstalk, the Python platform runs Gunicorn for you and finds the app through the WSGIPath setting.

Q14. How do you run a Spring Boot application on an EC2 server? Fresher
  • Build a jar: ./mvnw package creates target/shop-0.0.1.jar with an embedded web server.
  • Install a supported Java runtime, such as Amazon Corretto.
  • Run it as a systemd service: java -jar /opt/shop/shop.jar.
  • Set the port with server.port or the SERVER_PORT environment variable, for example 8080.
  • Put Nginx or an ALB in front for HTTPS.
  • Set memory with -Xmx so the JVM fits the instance memory, leaving room for the OS.

Spring Boot Actuator gives /actuator/health, which is a good health check path.

Q15. How do you host a WordPress or Laravel PHP site on AWS? Fresher

Simple options:

  • Amazon Lightsail with a WordPress blueprint, for small sites with a fixed monthly price.
  • EC2 with Nginx (or Apache) and PHP-FPM, plus RDS for MySQL.
  • Elastic Beanstalk PHP platform for Laravel, with RDS.

Important for Laravel: the web document root must be the public folder, not the project root.

For more than one server, store uploads in S3 or a shared EFS file system, and keep sessions in a database or cache, so all servers see the same data.

Q16. Where do application logs go when you host on ECS Fargate or Lambda? Fresher
  • Lambda: anything the function prints to standard output or error goes to CloudWatch Logs automatically, in a log group named /aws/lambda/<function-name>.
  • ECS Fargate: if the task definition uses the awslogs log driver, the container's stdout and stderr go to the chosen CloudWatch log group. FireLens can send logs to other destinations.

So the app should write logs to stdout and stderr, not to files inside the container, because the container's disk disappears when the task stops.

Set a retention period on each log group to control cost.

Q17. What is the difference between hosting on EC2 and hosting on Lambda for a small API? Fresher

EC2:

  • A server runs all the time, so you pay even when nobody uses it.
  • You patch the OS and runtime and handle scaling.
  • Good for long-running processes and full control.

Lambda:

  • Code runs only on requests. You pay per request and per duration.
  • No servers to patch. Scaling is automatic.
  • Limits apply, such as a 30-minute maximum for an on-demand Event Function invocation and request size limits, and the first request can have a cold start.

For a small API with uneven traffic, Lambda is usually cheaper and simpler.

3. Mid level questions

These questions check how you use the service in real projects. Interviewers expect the why, the how and one real example.

Q18. On Elastic Beanstalk, which port should your app listen on? Mid level

Elastic Beanstalk runs Nginx as a reverse proxy on most Linux platforms and forwards requests to your app on a fixed internal port.

The safest rule: read the PORT environment variable and listen on it, instead of hard-coding a number.

In current documentation, the default upstream is 8080 for the Node.js platform and 5000 for Java SE and Go. On the Python platform, Gunicorn is started for you. Check the docs for your platform version.

If the app listens on the wrong port, Nginx cannot reach it, and users see 502 Bad Gateway.

Q19. What is a Procfile and when do you use one on Elastic Beanstalk? Mid level

A Procfile tells the platform which command starts your application. Each line is process-name: command.

Example for a Python FastAPI app:

cat Procfile

Output:

web: gunicorn main:app --workers 3 --worker-class uvicorn.workers.UvicornWorker --bind 127.0.0.1:8000

The web process is Gunicorn with Uvicorn workers. The Python platform's Nginx forwards to port 8000.

Procfiles are supported on several Linux platforms, such as Python, Node.js, Go, Java SE and Ruby. Without one, the platform uses its default start method, such as npm start for Node.js.

Q20. How do you customise the Elastic Beanstalk environment, for example Nginx settings or packages? Mid level
  • .ebextensions/*.config: YAML files for option settings, packages, files and commands. Older but still common.
  • .platform folder: on Amazon Linux 2 and later platforms, put Nginx config in .platform/nginx/conf.d/ and scripts in .platform/hooks/prebuild, predeploy or postdeploy.
  • Environment properties in the console or eb setenv for environment variables.

Example: .platform/nginx/conf.d/upload.conf with client_max_body_size 20M; to allow bigger file uploads.

Keep all of this in Git, so every new environment gets the same settings.

Q21. Which deployment policies does Elastic Beanstalk offer, and which is safest? Mid level
  • All at once: fastest, but causes downtime and a bad version hits everything.
  • Rolling: updates batches of instances. Capacity drops during deploy.
  • Rolling with additional batch: launches extra instances first, so capacity stays full.
  • Immutable: launches a full new set of instances, tests them, then swaps. Safest in-place option, slower.
  • Traffic splitting: sends a percentage of traffic to new instances first, like a canary.

Blue/green is also possible by creating a second environment and swapping CNAMEs.

For production, use immutable or traffic splitting.

Q22. How do you deploy a containerised Node.js or Python API on ECS Fargate behind an ALB? Mid level
  • Write a Dockerfile, build the image and push it to Amazon ECR.
  • Create a task definition: image, CPU and memory, container port (for example 3000), environment variables, secrets, log configuration, and task role.
  • Create an ALB target group with target type ip and a health check path such as /health.
  • Create an ECS service in private subnets with the ALB, desired count 2 or more, and auto scaling.
  • Allow the ALB security group to reach the task security group on port 3000.

Then point Route 53 to the ALB and attach an ACM certificate to the HTTPS listener.

Q23. How do you run scheduled jobs, like a nightly report, for a web app hosted on AWS? Mid level

Do not rely on a cron entry on one web server. If that server is replaced or scaled to three copies, the job runs zero times or three times.

Better options:

  • EventBridge Scheduler that starts a Lambda function, an ECS task or a Step Functions workflow on a cron or rate schedule.
  • For Laravel's scheduler or Django management commands, run a one-off ECS task with the same image and a different command.
  • On Elastic Beanstalk, use a worker environment with a cron.yaml file.

Make jobs idempotent, so a retry does not send the same email twice, and alarm when a job fails.

Q24. How do you pass secrets like a database password to an ECS task without putting them in the image? Mid level

Use the secrets section of the container definition. It references a Secrets Manager secret or an SSM Parameter Store SecureString.

ECS reads the value when the task starts and injects it as an environment variable inside the container.

Example: DB_PASSWORD comes from arn:aws:secretsmanager:ap-south-1:111122223333:secret:shop/db-AbCdEf.

The task execution role needs permission to read that secret, and to use the KMS key if a customer managed key encrypts it.

Note: the value is read at start time. After rotation, restart the tasks or have the app read the secret directly.

Q25. How can you run an existing Express, Flask or Spring Boot web app on Lambda? Mid level

Lambda normally receives events, not HTTP connections, so you need an adapter between the event and the web framework.

Options:

  • AWS Lambda Web Adapter: an open-source tool that lets a normal web app listening on a port run inside Lambda, often packaged as a container image.
  • Framework adapters, such as Mangum for ASGI apps like FastAPI.
  • Expose it with a Lambda function URL or API Gateway.

Check the fit first: long requests, WebSockets, large uploads and heavy startup times may suit containers better.

Q26. How do you reduce cold starts for Java or .NET functions on Lambda? Mid level

Java and .NET runtimes can take longer to start because of class loading and framework setup.

Options:

  • Lambda SnapStart: Lambda takes a snapshot of the initialised function and resumes from it. It supports Java, and AWS has extended it to Python and .NET runtimes.
  • Provisioned concurrency: keeps a set number of environments ready, at extra cost.
  • Lighter frameworks or ahead-of-time compilation, and smaller packages.
  • More memory, which also gives more CPU.

Measure with the Init Duration in the REPORT log line before and after.

Q27. What is the API Gateway timeout trap when hosting an API on Lambda? Mid level

An on-demand Lambda Event Function can run for up to 30 minutes, but API Gateway has its own integration timeout, which can be much shorter.

For HTTP APIs, the maximum integration timeout is 30 seconds. For REST APIs the default is 29 seconds, and AWS allows raising it for Regional and private REST APIs with a quota increase, which can reduce throttle limits.

So long tasks, such as generating a large report, should not run inside the request. Instead, accept the request, put a job on SQS or Step Functions, return 202 Accepted, and let the client check the status later.

Q28. How do you host a .NET application on AWS? Mid level
  • Elastic Beanstalk: .NET on Windows Server with IIS for classic ASP.NET apps, or .NET Core on Linux for modern .NET.
  • ECS on Fargate: package an ASP.NET Core app in a Linux container. Windows containers are possible but heavier.
  • Lambda: the managed .NET runtime for functions and APIs.
  • EC2 Windows: for apps that need the full Windows environment.

For modern ASP.NET Core, Linux containers are usually the cheapest and easiest to scale. The app listens on a port set by ASPNETCORE_URLS or ASPNETCORE_HTTP_PORTS, and the health check uses a /health endpoint.

Q29. How do you serve static files for a Django or Laravel app in production on AWS? Mid level

The app server should not waste time sending images, CSS and JavaScript.

  • Django: run collectstatic and upload static files to S3, then serve them through CloudFront, for example with the django-storages package. Media uploads also go to S3.
  • Laravel: build assets (Vite) during the pipeline, and serve /build through CloudFront or Nginx. Store user uploads on S3 using Laravel's S3 filesystem driver.
  • Add cache headers, and use file names with content hashes so you can cache for a long time.

This keeps servers stateless and fast.

Q30. Why does an app behind an ALB or CloudFront think every request is HTTP and create redirect loops? Mid level

TLS ends at the load balancer or CloudFront. The app then receives plain HTTP, so it thinks the user is on HTTP and redirects to HTTPS again and again.

Fix: tell the framework to trust the X-Forwarded-Proto header from the proxy:

  • Express: app.set('trust proxy', 1).
  • Django: SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https').
  • Laravel: configure trusted proxies.
  • Spring Boot: server.forward-headers-strategy=native.

Only trust headers from your own proxy, not from the internet.

Q31. How do you deploy a Go or Ruby web app on AWS? Mid level

Go:

  • Build one static binary, for example for linux/arm64 for Graviton.
  • Run it on EC2 with systemd, in a tiny container image on Fargate, on Elastic Beanstalk's Go platform, or on Lambda with the OS-only runtime (provided.al2023) using a bootstrap binary.

Ruby (Rails or Sinatra):

  • Run with the Puma application server behind Nginx or an ALB.
  • Elastic Beanstalk's Ruby platform uses Puma and Nginx.
  • Precompile assets in the pipeline and run database migrations as a separate controlled step.
Q32. What should a good Dockerfile for a production web app include? Mid level
  • A small official base image with a pinned version, for example node:22-slim or python:3.13-slim.
  • Multi-stage build: build tools in the first stage, only the runtime and app in the final stage.
  • Install dependencies before copying source code, so Docker caches layers.
  • Run as a non-root user.
  • Use EXPOSE for the app port and a clear CMD.
  • Do not copy .env files or secrets. Use .dockerignore.

Scan the image in ECR with image scanning before deploying.

Q33. How do you run database migrations safely when deploying a web app on AWS? Mid level
  • Run migrations as a separate step in the pipeline, for example a one-off ECS task or a CodeBuild job, not on every container start.
  • Make migrations backward compatible: add columns first, deploy code that uses them, and remove old columns in a later release. This is the expand and contract pattern.
  • Take a snapshot or confirm point-in-time restore before risky changes.
  • Make sure only one migration job runs at a time.

This lets old and new versions of the app run side by side during a rolling deploy.

Q34. How do you scale a web app on ECS Fargate automatically? Mid level

Use ECS service auto scaling with Application Auto Scaling.

  • Target tracking on average CPU, for example keep CPU at 60%.
  • Or on ALBRequestCountPerTarget, which follows real traffic better for web apps.
  • Set a minimum of 2 tasks in different AZs, and a sensible maximum to protect cost and the database.
  • Use scheduled scaling before a known sale.

Check that the database and downstream services can handle the maximum number of tasks.

Q35. What is the difference between hosting on Amazon Lightsail and on EC2? Mid level

Lightsail gives simple virtual servers, databases and load balancers with a fixed monthly price, including some data transfer. It has ready blueprints such as WordPress, LAMP and Node.js.

EC2 gives full control: many instance types, Auto Scaling, advanced networking and integration with all VPC features.

Choose Lightsail for small sites, blogs and simple apps where predictable cost and simplicity matter. Choose EC2, ECS or Elastic Beanstalk when you need scaling, high availability and deeper integration.

4. Senior level and scenario questions

These questions check design thinking and troubleshooting. Think aloud. Say what you check first, what you change, and how you prevent it next time.

Q36. After a deploy, users get 502 Bad Gateway from Nginx or the ALB. How do you troubleshoot? Senior

502 means the proxy reached out to the app but got no valid response.

  • Is the app process running? Check systemctl status, ECS task status, or Elastic Beanstalk health.
  • Is it listening on the expected port and interface? ss -tlnp should show 0.0.0.0:3000 or 127.0.0.1:3000 as configured. Listening on the wrong port is very common.
  • Did it crash on start? Read the logs for missing environment variables or failed database connections.
  • Check the Nginx error log for "connect() failed (111: Connection refused)" or "upstream prematurely closed connection".
  • On an ALB, check that the target's keep-alive timeout is longer than the ALB idle timeout.

Roll back first if users are affected, then debug.

Q37. An ECS service keeps starting and stopping tasks after a deploy. What do you check? Senior
  • Stopped reason in the ECS console: image pull error, essential container exited, or failed ELB health checks.
  • Image pull errors: wrong tag, no ECR permission on the execution role, or no route to ECR from private subnets (needs NAT or VPC endpoints).
  • Container exits: read CloudWatch logs for crashes, such as a missing secret or wrong command.
  • Health check failures: wrong port or path in the target group, the app starts slower than the health check grace period, or the security group blocks the ALB.

Turn on the deployment circuit breaker with rollback, so a broken release rolls back automatically.

Q38. Design hosting for a React front end and a Python API that must handle sudden traffic spikes. Senior
  • Front end: S3 plus CloudFront with long cache times for hashed assets, short cache for index.html.
  • API: FastAPI in containers on ECS Fargate behind an ALB, or on Lambda behind API Gateway if requests are short.
  • Database: RDS or Aurora with RDS Proxy, plus ElastiCache for hot reads.
  • Slow work, such as emails and PDFs, goes to SQS and worker tasks.
  • Auto scaling with a warm minimum, and AWS WAF rate limits on CloudFront.
  • Route 53 and ACM for the domain and HTTPS.

Explain how each layer absorbs the spike.

Q39. A legacy PHP application stores uploaded files and sessions on the local disk. How do you make it run on several servers? Senior

Problem: with two servers behind a load balancer, a file uploaded to server A is missing on server B, and users lose their login when the next request goes to the other server.

Fix in steps:

  • Sessions: move them to a database or ElastiCache (Redis-compatible) session handler.
  • Uploads: change code to store files in S3. If code changes are hard, mount a shared EFS file system as a short-term fix.
  • Remove any local cron jobs that must run once, and move them to a scheduler.
  • Then put the servers in an Auto Scaling group behind an ALB.

Sticky sessions can hide the session problem, but they do not fix it.

Q40. How would you move a Node.js app from one EC2 server to a highly available setup with no downtime? Senior
  • Make the app stateless: sessions to a shared store, files to S3, config from environment variables and Secrets Manager.
  • Create an AMI or container image of the app.
  • Build an ALB with a target group, and an Auto Scaling group (or ECS service) across two or three AZs.
  • Test the new stack with a temporary DNS name.
  • Lower the Route 53 TTL in advance, then switch the record to the ALB, or use weighted records to move traffic slowly.
  • Keep the old server running until traffic and errors look normal, then retire it.
Q41. A Spring Boot container on Fargate is killed with exit code 137 under load. What is happening? Senior

Exit code 137 means the process received SIGKILL, usually because the container used more memory than its limit (out of memory).

For Java:

  • The JVM heap plus metaspace, threads and native memory must fit in the task memory.
  • Modern JVMs read container limits. Set -XX:MaxRAMPercentage (for example 75) rather than a fixed -Xmx that may be too big.
  • Check for memory leaks or very large in-memory caches with heap dumps in a test environment.

Fix: right-size task memory, tune JVM settings, and alarm on memory utilisation. Also check the stopped reason in ECS, which often says "OutOfMemoryError: Container killed due to memory usage".

Q42. You host a static site on S3 and CloudFront, but users still see the old version after a deploy. Why and how do you fix it? Senior

CloudFront edge caches and browsers keep the old files until their cache time ends.

Good fix (by design):

  • Give built assets content-hashed names, such as main.3f9a2c.js, and cache them for a long time.
  • Serve index.html with a short cache time or no-cache, so browsers always get the latest list of assets.
  • After each deploy, create an invalidation only for /index.html (or a few paths).
aws cloudfront create-invalidation --distribution-id E1ABCDEF234567 --paths "/index.html"

Output:

"Status": "InProgress"

CloudFront is removing the cached index.html from edge locations. Invalidating "/*" works too, but it is a heavy habit.

Q43. How do you choose between Elastic Beanstalk, ECS Fargate and Lambda for a new web app? Senior
  • Lambda: event-driven or spiky APIs with short requests, small teams, pay-per-use. Watch the on-demand timeout of up to 30 minutes, API integration timeouts, payload sizes and cold starts.
  • ECS Fargate: containers for any language, long-running services, WebSockets, steady traffic, and teams that want control without managing servers.
  • Elastic Beanstalk: teams that want a simple path for a traditional web app on EC2, with managed platform updates and little container knowledge.

Also consider: existing skills, CI/CD tools, cost at expected traffic, and compliance needs. App Runner is no longer an option for new customers, and AWS points them to ECS Express Mode.

Q44. An existing App Runner customer asks whether to stay or move. What do you advise? Senior

Facts: App Runner stopped accepting new customers on 30 April 2026. Existing customers can keep using it, including creating new services, and AWS continues security and availability work, but plans no new features. AWS recommends Amazon ECS Express Mode and publishes a migration guide.

Advice:

  • No panic: running services keep working.
  • For new services, prefer ECS (Express Mode or standard ECS on Fargate), so you have one platform.
  • Plan a gradual move: create the ECS service with the same image, then shift traffic with Route 53 weighted records and keep a rollback path.
Q45. A deploy pipeline built the app successfully, but production shows "Cannot find module" or "ModuleNotFoundError". What went wrong? Senior

The code was built in one environment but run in another that is missing dependencies.

Common causes:

  • Node.js: devDependencies used at runtime, node_modules not included in the artifact, or native modules built for a different CPU architecture (x86 vs Graviton arm64).
  • Python: packages installed on the build machine but not into the deployment package or image, or wheels built for the wrong platform.
  • Case-sensitive import paths that worked on a Mac but fail on Linux.

Fix: build inside the same base image or platform as production, lock dependency versions, and run a smoke test of the final artifact before release.

Q46. How do you make a WordPress site on AWS fast and resilient for a news website? Senior
  • CloudFront in front, caching pages for anonymous users, with cache bypass for logged-in editors and the admin area.
  • WordPress on two or more EC2 instances or containers in different AZs behind an ALB.
  • Media uploads offloaded to S3, or a shared EFS volume for wp-content if plugins require it.
  • RDS for MySQL Multi-AZ, plus an object cache in ElastiCache.
  • AWS WAF with managed rules for common WordPress attacks, and rate limits on wp-login.php.
  • Automated backups, and plugin updates tested on staging first.
Q47. How do you set up zero-downtime deployments for a web app on EC2 Auto Scaling? Senior
  • Bake each release into a new AMI or use CodeDeploy to install it.
  • Use instance refresh, or CodeDeploy blue/green with a new set of instances, so old instances stay until new ones are healthy.
  • Make the health check real, and set a sensible health check grace period.
  • Use the ALB deregistration delay so in-flight requests finish.
  • Keep database changes backward compatible.
  • Add alarms for 5xx errors and latency, with automatic rollback.

Test a rollback in staging, so you know it works when you need it.

Q48. Users from one country report that the site loads but the API calls fail with CORS errors. How do you investigate? Senior

CORS errors are reported by the browser when the API response lacks the right Access-Control-Allow-* headers for the calling site.

Check:

  • The browser network tab: which origin calls which API URL, and does the preflight OPTIONS request fail?
  • Is that country served by a different domain or CloudFront distribution, such as shop.co.in instead of shop.com, that is missing from the allowed origins?
  • Does CloudFront forward the Origin header, and does the cache key include it, so a response for one origin is not reused for another?
  • Is a WAF rule blocking OPTIONS requests from that region?

Fix the allowed origins list in the API and the CloudFront cache policy, then test from that origin.

Q49. Your Node.js API on EC2 slows down and memory keeps growing until the server swaps. How do you investigate? Senior
  • Confirm with metrics: memory from the CloudWatch agent, and process memory with ps or top on the server.
  • Check whether it grows with traffic and never falls back. That points to a memory leak, such as a global cache without limits or event listeners that are never removed.
  • Take heap snapshots in a test environment with the same traffic, and compare them over time.
  • Short-term: restart the process on a schedule or when memory crosses a limit (systemd MemoryMax or PM2 max_memory_restart), and run at least two instances so restarts do not cause downtime.
  • Long-term: fix the leak, set cache size limits and add a memory alarm.
Q50. How do you host several small apps in different languages cheaply but safely on AWS? Senior
  • Put each app in its own container image, so language versions do not conflict.
  • Run them as separate ECS services on Fargate (or on a small EC2-backed cluster for lower cost), each with its own task role and security group.
  • Share one ALB with host-based or path-based listener rules, such as api.example.com and admin.example.com, to save on load balancer cost.
  • Use one ACM certificate with the needed names, and Route 53 alias records.
  • Separate secrets per app in Secrets Manager.
  • Set minimum task counts and schedules based on real traffic.

This keeps isolation per app while sharing the expensive parts.

5. Frequently asked questions

Which hosting option should a beginner learn first?

Start with a static site on S3 and CloudFront, then one app on EC2 with Nginx, so you understand ports, processes and logs. After that, learn containers on ECS Fargate, which most companies use today.

Is App Runner still a good choice?

AWS App Runner stopped accepting new customers on 30 April 2026. Existing customers can keep using it, but AWS recommends Amazon ECS Express Mode for new container apps. Check the current AWS page before you suggest it.

Do I need to know every language?

No. The hosting ideas are the same: build, start command, port, environment variables, health check, logs. Learn one language deeply and know what changes for the others.

6. Quick revision

  • Static sites: S3 plus CloudFront plus ACM in us-east-1.
  • Apps behind Nginx or an ALB listen on an internal port. The proxy handles port 80 and 443.
  • Health checks must hit a fast path that really tests the app.
  • Never put secrets in code or images. Use Secrets Manager or Parameter Store.
  • Most 502 errors mean the proxy could not talk to the app.

This page is one part of a 1000-question AWS interview set. Open the full list here: All 1000 AWS interview questions.