Cloud & DevOps

15 questions found

What is a twelve-factor app, and how does it guide how a Node.js application should be configured for cloud deployment?

Intermediate
The twelve-factor methodology is a set of best practices for cloud-native apps: storing configuration in environment variables (so the same build deploys unchanged across environments), treating backing services as attached resources via a URL, keeping the app stateless so any instance can handle any request, and logging to stdout rather than managing log files directly.
const config = {
  port: process.env.PORT || 3000,
  databaseUrl: process.env.DATABASE_URL,
};

console.log(JSON.stringify({ level: 'info', message: 'Server started' }));
Real-world example A twelve-factor Node.js API deploys unchanged to a laptop, staging, and production simply by supplying different environment variables, without separate config files or code branches per environment.

Common follow-ups: Why does storing state on a specific instance's local disk violate the stateless principle, and what's the cloud-native alternative?;How does this methodology specifically enable horizontal auto-scaling?

Environment Variables & Configuration;Docker & Containerization for Node.js

What is a health check endpoint, and how does an orchestrator like Kubernetes use liveness and readiness probes differently?

Advanced
Kubernetes distinguishes liveness probes (is the process alive and not deadlocked? failing restarts the container) from readiness probes (is the instance ready for traffic right now? failing just removes it from the load balancer temporarily, without restarting), since a temporarily overloaded but otherwise healthy instance should stop receiving traffic without a needless restart.
app.get('/healthz/live', (req, res) => res.status(200).send('OK'));

app.get('/healthz/ready', async (req, res) => {
  const dbOk = await checkDatabaseConnection();
  res.status(dbOk ? 200 : 503).send(dbOk ? 'Ready' : 'Not ready');
});
Real-world example A service that temporarily loses its database connection fails its readiness probe (removed from traffic without a disruptive restart) while still passing liveness, rejoining traffic once the connection is restored.

Common follow-ups: What's the risk of making the liveness probe check external dependencies rather than just the process's own health?;How do you tune failureThreshold and periodSeconds to avoid both false positives and slow detection?

Docker & Containerization for Node.js;Deployment & Process Managers (PM2)

What is a CI/CD pipeline for a Node.js application, and what stages does a typical one include?

Advanced
A typical pipeline includes: installing dependencies, running linters/type checks, running the test suite, building a production artifact (a Docker image), and deploying it to staging then production, often with manual approval gates or automated canary/blue-green rollout strategies for production.
name: CI
on: [push]
jobs:
  test:
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
      - run: npm ci
      - run: npm run lint
      - run: npm test
      - run: docker build -t myapp:${{ github.sha }} .
Real-world example A team's pipeline runs the full test suite and builds a Docker image on every pull request, blocking merges until tests pass, and auto-deploys to staging on merge with a manual approval step for production.

Common follow-ups: What's the difference between continuous delivery and continuous deployment, given both are abbreviated CD?;How would you add a rollback mechanism in case a deployed change causes issues?

Docker & Containerization for Node.js;Git & Project Management

What is infrastructure as code (IaC), and how might a Node.js team use a tool like Terraform or the AWS CDK alongside their application code?

Intermediate
IaC defines cloud infrastructure in version-controlled configuration rather than manual console clicks, enabling reproducible, reviewable infrastructure changes. The AWS CDK lets teams define infrastructure using actual TypeScript/JavaScript code rather than a separate declarative language, letting a Node.js team reuse familiar tooling for infrastructure too.
const fn = new lambda.Function(this, 'ApiHandler', {
  runtime: lambda.Runtime.NODEJS_20_X,
  handler: 'index.handler',
  code: lambda.Code.fromAsset('dist'),
});
new apigateway.LambdaRestApi(this, 'Api', { handler: fn });
Real-world example A team migrating from manually configured AWS resources to the CDK captures their entire infrastructure as version-controlled TypeScript, letting infrastructure changes go through the same PR review process as application code.

Common follow-ups: What's the tradeoff of using the CDK versus a purely declarative tool like Terraform?;How do you handle infrastructure state drift when using IaC alongside occasional manual console changes?

Serverless Node.js (AWS Lambda & Functions);Git & Project Management

What is horizontal scaling for a Node.js application, and what specific architectural requirement does it impose?

Advanced
Horizontal scaling adds more instances behind a load balancer rather than making one instance more powerful -- this requires the application to be stateless: any instance must handle any request without depending on data that only exists on one instance, which is why session state needs a shared store like Redis and uploads need shared storage like S3.
// Stateful (breaks horizontal scaling)
app.use(session({ secret: 'x' }));

// Stateless: session in shared Redis
app.use(session({ store: new RedisStore({ client: redisClient }), secret: process.env.SESSION_SECRET }));
Real-world example An application that worked with a single instance started randomly logging users out after being scaled to three instances, traced to in-memory sessions, fixed by moving to Redis-backed sessions.

Common follow-ups: How does sticky sessions at the load balancer offer a partial alternative to making the app fully stateless?;What's the difference between horizontal scaling and Node's built-in cluster module?

Clustering & Worker Threads;Authentication & Authorization (JWT OAuth Passport)

What is a load balancer, and how does it distribute traffic across multiple Node.js application instances?

Intermediate
A load balancer sits in front of multiple instances, distributing requests according to an algorithm (round-robin, least-connections, IP-hash), improving availability (traffic routes only to healthy instances) and throughput, commonly implemented via a managed cloud load balancer or software like Nginx or HAProxy.
upstream node_app {
  server 10.0.0.1:3000;
  server 10.0.0.2:3000;
}
server {
  listen 80;
  location / { proxy_pass http://node_app; }
}
Real-world example A production API runs three instances behind an AWS ALB configured with health checks, so a crashed instance is automatically removed from rotation until it recovers.

Common follow-ups: How does the load balancer itself avoid becoming a single point of failure?;What's the difference between Layer 4 and Layer 7 load balancing, and when does it matter for a Node.js app?

HTTP & HTTPS Modules;Docker & Containerization for Node.js

What is a blue-green deployment, and how does it minimize downtime and risk when deploying a new version of a Node.js application?

Advanced
Blue-green deployment maintains two identical environments -- the new version is deployed and tested against 'green' while 'blue' serves all live traffic, and once verified, traffic is switched instantly, with blue kept running briefly as an instant rollback target.
aws elbv2 modify-listener \
  --listener-arn $LISTENER_ARN \
  --default-actions Type=forward,TargetGroupArn=$GREEN_TARGET_GROUP_ARN
Real-world example A payments API deploys an update to a parallel green environment, smoke-tests it while blue serves real traffic, and switches the load balancer to green only after verification passes.

Common follow-ups: How does blue-green deployment compare to canary release in terms of risk exposure?;What's the cost implication of running two full production environments simultaneously?

Docker & Containerization for Node.js;Deployment & Process Managers (PM2)

What role do secret managers (like AWS Secrets Manager) play in deploying a Node.js app across dev, staging, and production?

Intermediate
Sensitive values (API keys, database passwords) should ideally come from a dedicated secrets manager rather than plain environment variables or files, since secrets managers provide encryption at rest, access control, and audit logging that plain environment variables typically don't.
const client = new SecretsManagerClient({ region: 'us-east-1' });
const secret = await client.send(new GetSecretValueCommand({ SecretId: 'prod/database' }));
const { password } = JSON.parse(secret.SecretString);
Real-world example A team migrates database credentials from a plain .env file to AWS Secrets Manager, gaining automatic credential rotation and a full audit trail of secret access.

Common follow-ups: What's the specific security risk of environment variables versus a dedicated secrets manager?;How do you handle secret rotation without requiring a full redeploy?

Environment Variables & Configuration;Security

What is auto-scaling, and what metrics commonly trigger scaling decisions for a Node.js service running in the cloud?

Advanced
Auto-scaling automatically adjusts running instance count based on demand -- common triggers include CPU utilization, memory usage, request latency, and queue depth for background-job services, since a growing backlog signals worker capacity falling behind incoming volume.
{
  "TargetValue": 60.0,
  "PredefinedMetricSpecification": { "PredefinedMetricType": "ECSServiceAverageCPUUtilization" },
  "ScaleOutCooldown": 60,
  "ScaleInCooldown": 300
}
Real-world example An e-commerce platform auto-scales when CPU exceeds 60% for two minutes, handling a traffic surge without manual intervention, then scales down overnight.

Common follow-ups: Why is scale-in cooldown typically set longer than scale-out cooldown?;How does auto-scaling a stateless HTTP API differ from auto-scaling a background-job worker fleet?

Background Jobs & Queues;Performance Optimization & Profiling

What is a reverse proxy, and why is Nginx commonly placed in front of a Node.js application in production?

Intermediate
A reverse proxy forwards client requests to backend servers -- Nginx is placed in front of Node.js to handle TLS termination, serve static files directly, provide basic load balancing, and buffer slow client connections so they can't tie up limited Node.js concurrency.
server {
  listen 443 ssl;
  location /static/ { root /var/www; }
  location / { proxy_pass http://localhost:3000; }
}
Real-world example A production API runs behind Nginx, which handles TLS certificates and serves static assets directly without involving the Node.js process at all.

Common follow-ups: How does the Node.js app read the real client IP when requests are proxied through Nginx?;What's the tradeoff of terminating TLS at Nginx versus in the Node.js process directly?

HTTP & HTTPS Modules;Security

Showing 1–10 of 15