🌍 NodeJS · subject

NodeJS Deployment Syllabus

The Deployment syllabus for NodeJS in full: 2 chapters and 6 topics, every one listed below, plus 50 Deployment flashcards with answers.

2Chapters
6Topics
50Flashcards

Deployment syllabus: all 2 chapters

Expand any chapter to see its topics and sub-topics.

  1. Deployment Strategies

    3 topics
    • PM2
    • Docker
    • CI/CD Pipelines
  2. Cloud Providers

    3 topics
    • AWS
    • Heroku
    • Google Cloud Platform

NodeJS Deployment flashcards — 50 questions with answers

  1. What is PM2 in the Node.js ecosystem?

    PM2 is a production process manager for Node.js applications with a built-in load balancer. It keeps apps alive forever, reloads them without downtime, and manages logging, monitoring, and clustering.

  2. Which PM2 command starts an app and keeps it running under the process manager?

    pm2 start app.js (optionally with --name, --watch, or -i for instances). This launches the app as a managed, auto-restarting process.

  3. How does PM2 cluster mode scale a Node.js app across CPU cores?

    pm2 start app.js -i max (or a number) forks N worker processes using Node's cluster module, load-balancing incoming connections across cores. Optimal N is typically the number of CPU cores.

  4. What is the difference between pm2 restart and pm2 reload?

    restart kills and restarts the process (causes brief downtime). reload does a zero-downtime rolling restart in cluster mode, starting new workers before killing old ones.

  5. How do you make PM2-managed apps survive a server reboot?

    Run pm2 startup (generates and installs an init script) then pm2 save (snapshots the current process list to be resurrected on boot).

  6. What file does PM2 use for declarative multi-app configuration?

    An ecosystem file, typically ecosystem.config.js, defining an apps array with settings like name, script, instances, exec_mode, env, and watch.

  7. Which PM2 command shows a live dashboard of CPU, memory, and logs?

    pm2 monit gives a real-time terminal dashboard; pm2 logs streams aggregated logs; pm2 list shows a status table.

  8. What does PM2's max_memory_restart option do?

    It automatically restarts a process when its memory usage exceeds a threshold (e.g. max_memory_restart: '300M'), guarding against memory leaks.

  9. What is a Docker image versus a Docker container?

    An image is a read-only template (layered filesystem plus metadata) built from a Dockerfile. A container is a running, writable instance of an image with its own isolated process, network, and filesystem namespace.

  10. What is a Dockerfile?

    A text file of sequential instructions (FROM, RUN, COPY, CMD, etc.) that Docker reads to build an image. Each instruction generally creates a new cached layer.

  11. What is the purpose of the FROM instruction in a Dockerfile?

    FROM sets the base image the build starts from (e.g. FROM node:20-alpine). It must be the first non-comment instruction and defines the initial filesystem and OS layer.

  12. What is the difference between the CMD and ENTRYPOINT instructions?

    ENTRYPOINT defines the fixed executable that always runs; CMD provides default arguments (or the default command) that are easily overridden at runtime. Combined, ENTRYPOINT is the command and CMD supplies its default args.

  13. What is a multi-stage Docker build and why use it?

    A Dockerfile with multiple FROM stages where build artifacts are copied from a heavy build stage into a slim final stage. It produces smaller, more secure production images by excluding build tools and dev dependencies.

  14. What is the difference between COPY and ADD in a Dockerfile?

    COPY simply copies local files/directories into the image. ADD does the same but additionally can auto-extract local tar archives and fetch remote URLs. Best practice: prefer COPY unless you need ADD's extra features.

  15. What is the difference between a Docker volume and a bind mount?

    A volume is Docker-managed storage stored in Docker's area and decoupled from the host path structure. A bind mount maps a specific host directory into the container. Volumes are preferred for portability and backups; bind mounts for live source during development.

  16. What does the EXPOSE instruction actually do in Docker?

    EXPOSE documents which port the container listens on; it does NOT publish the port. You must still map it at runtime with docker run -p hostPort:containerPort.

  17. What is the role of a .dockerignore file?

    It lists files/directories excluded from the build context sent to the Docker daemon (e.g. node_modules, .git). This speeds builds, shrinks context, and avoids leaking secrets into images.

  18. How does Docker layer caching affect build order for a Node.js app?

    Copy package.json and package-lock.json and run npm install BEFORE copying source code. Because layers cache until an input changes, dependencies are only reinstalled when the manifest changes, not on every code edit.

  19. What is Docker Compose used for?

    Docker Compose defines and runs multi-container applications via a YAML file (compose.yaml). docker compose up starts all defined services, networks, and volumes together with one command.

  20. What is CI/CD?

    CI (Continuous Integration) is the practice of frequently merging code and automatically building/testing it. CD (Continuous Delivery/Deployment) automatically prepares and releases those validated changes to staging or production.

Show the other 30 Deployment flashcards
  1. What is the difference between Continuous Delivery and Continuous Deployment?

    In Continuous Delivery every change is automatically built, tested, and made release-ready, but the final push to production is a manual approval. In Continuous Deployment that final step is also automated, so every passing change ships to production without human intervention.

  2. What are the typical stages of a CI/CD pipeline?

    Source (trigger on commit/PR) → Build (compile/package) → Test (unit, integration, lint) → Release/Artifact → Deploy (staging/production) → optional Monitor. Each stage gates the next.

  3. What is a build artifact in a CI/CD pipeline?

    A deployable output produced by the build stage (e.g. a Docker image, a zipped bundle, or a compiled binary) that is stored and passed to later deploy stages to ensure the exact same tested code is released.

  4. What triggers a CI pipeline run in GitHub Actions?

    Events defined under the on: key, such as push, pull_request, schedule (cron), or workflow_dispatch (manual). Workflows are YAML files stored in .github/workflows/.

  5. What is the difference between blue-green and canary deployment strategies?

    Blue-green keeps two identical environments and switches all traffic at once from blue (old) to green (new), enabling instant rollback. Canary releases the new version to a small percentage of users first, then gradually increases if healthy.

  6. What is a rolling deployment?

    A strategy that incrementally replaces old instances with new ones a few at a time, so the app stays available throughout. It needs no duplicate environment but makes instant full rollback harder than blue-green.

  7. Why are secrets stored as encrypted CI/CD variables rather than in the repository?

    To prevent credential leakage in source history. CI systems inject secrets (API keys, tokens) as masked environment variables at runtime, keeping them out of code and logs.

  8. What is Infrastructure as Code (IaC) and how does it relate to deployment pipelines?

    IaC manages infrastructure through machine-readable definition files (e.g. Terraform, CloudFormation) instead of manual setup. Pipelines apply these files to provision reproducible, version-controlled environments automatically.

  9. What is Amazon EC2?

    Elastic Compute Cloud — AWS's IaaS offering that provides resizable virtual servers (instances) on demand. You manage the OS, runtime, and app; AWS manages the underlying hardware.

  10. What is AWS Elastic Beanstalk?

    A PaaS that automatically handles provisioning, load balancing, scaling, and health monitoring for uploaded application code (including Node.js). You deploy code; Beanstalk manages the EC2 infrastructure underneath.

  11. What is AWS Lambda and what pricing model does it use?

    Lambda is a serverless, event-driven compute service that runs functions without provisioning servers. You pay only for the number of requests and compute duration (GB-seconds); there is no charge when code isn't running.

  12. What is Amazon S3 primarily used for?

    Simple Storage Service — scalable object storage for files (static assets, backups, build artifacts, media). It is not a filesystem or block store; data is stored as objects in buckets accessed via keys.

  13. What is the difference between AWS EC2, ECS, and Lambda for running an app?

    EC2 gives full VMs you manage (IaaS). ECS/Fargate runs Docker containers as managed services. Lambda runs stateless functions serverlessly. They trade increasing abstraction for decreasing operational control.

  14. What is an AWS security group?

    A virtual stateful firewall attached to instances that controls inbound and outbound traffic by rules (protocol, port, source/destination). Being stateful, return traffic for an allowed inbound request is automatically permitted.

  15. What does an AWS Auto Scaling Group do?

    It automatically adjusts the number of EC2 instances up or down based on demand, health checks, and scaling policies, keeping the fleet between a defined minimum and maximum size.

  16. What is Amazon ECR?

    Elastic Container Registry — a managed private Docker image registry on AWS used to store, version, and pull container images for services like ECS, EKS, and Lambda.

  17. What role does an AWS Elastic Load Balancer play in deployment?

    It distributes incoming traffic across multiple healthy targets (instances/containers) in one or more Availability Zones, improving fault tolerance and enabling zero-downtime rolling and blue-green deployments.

  18. What is Heroku in one sentence?

    Heroku is a container-based Platform-as-a-Service (PaaS) that lets developers deploy, run, and scale apps (including Node.js) without managing servers, using a git-push-to-deploy workflow.

  19. What is a dyno in Heroku?

    A dyno is a lightweight, isolated Linux container that runs a single command defined in the app; it is Heroku's basic unit of compute. Apps scale by adjusting dyno size and count.

  20. How do you deploy an app to Heroku using Git?

    Push to the Heroku remote: git push heroku main. Heroku detects the buildpack, builds a slug, and releases it automatically.

  21. What is the purpose of a Procfile in Heroku?

    The Procfile declares the process types and commands Heroku runs, e.g. web: node server.js. The 'web' process type receives external HTTP traffic routed by Heroku.

  22. How must a Node.js app read its port on Heroku, and why?

    It must listen on process.env.PORT rather than a hardcoded port, because Heroku dynamically assigns the port and routes external traffic to it. Hardcoding a port causes bind failures.

  23. What is a Heroku buildpack?

    A set of scripts that detect an app's language and transform the source into an executable slug by installing dependencies and runtimes (e.g. the Node.js buildpack runs npm install).

  24. How do Heroku dynos handle local file storage?

    Dynos have an ephemeral filesystem that is wiped on every restart or deploy (dyno cycling ~every 24h). Persistent data must be kept in add-on databases or object storage like S3, not local files.

  25. What are Heroku config vars used for?

    They are environment variables (set via heroku config:set KEY=value or the dashboard) that inject configuration and secrets like DATABASE_URL into the app at runtime, keeping them out of source code.

  26. What is Google Cloud Platform's App Engine?

    App Engine is a fully managed PaaS on GCP that runs applications (including Node.js) and auto-scales them without server management. The Standard environment uses managed sandboxes; the Flexible environment runs apps in Docker containers on VMs.

  27. What is Google Cloud Run?

    A fully managed serverless platform that runs stateless containers, auto-scaling from zero to many instances based on request load, and billing only for resources used during request handling.

  28. What is the difference between GCP Compute Engine and App Engine?

    Compute Engine is IaaS providing configurable virtual machines you manage. App Engine is PaaS that runs your code and handles scaling, patching, and infrastructure for you.

  29. What is Google Kubernetes Engine (GKE)?

    GKE is GCP's managed Kubernetes service for deploying, orchestrating, and scaling containerized applications, with Google managing the control plane, upgrades, and node health.

  30. How do App Engine, Cloud Run, and GKE on GCP compare in abstraction and container control?

    App Engine (PaaS) offers the most abstraction with least control; Cloud Run runs individual stateless containers serverlessly with moderate control; GKE gives full Kubernetes orchestration and the most control at the cost of more operational overhead.

NodeJS Deployment FAQ

What is in the NodeJS Deployment syllabus?

NodeJS Deployment is split into 2 chapters: Deployment Strategies and Cloud Providers. Together they contain 6 topics.

How many chapters are in NodeJS Deployment?

2 chapters, containing 6 topics. The largest chapter is Deployment Strategies, with 3 topics.

Are there flashcards for NodeJS Deployment?

Yes — a 50-card Deployment deck, printed in full in the flashcards section of this page and available in the Examius app with spaced repetition. The free plan covers one exam of your choice, including its flashcards; Examius Pro, a one-time purchase, unlocks every other exam and deck.