Part 5 Exercises
Deploy something. Each exercise below is a real task a working DevOps engineer does regularly.
Node.js & PM2
What is PM2 and why is it necessary instead of just running node server.js in production? Name at least three things PM2 provides that a raw node process doesn't.
Write the PM2 CLI command to start index.js, name the process my-api, use cluster mode with the maximum number of CPU cores, and then save the process list for survival across reboots.
Write a minimal ecosystem.config.js for a Node.js app that: runs dist/server.js in cluster mode, limits restarts if memory exceeds 300 MB, and sets NODE_ENV=production.
What is the difference between pm2 restart and pm2 reload? When would you use each?
Python & FastAPI
What is the difference between WSGI and ASGI? Which standard does FastAPI use and why does it matter for concurrency?
You have a 4-core server. How many Gunicorn workers should you run for a FastAPI application? Write the complete gunicorn command using Uvicorn workers.
Write a Dockerfile for a FastAPI app that installs dependencies from requirements.txt and starts Gunicorn with 4 Uvicorn workers on port 8000.
What does alembic upgrade head do? Why should you run this as part of a deployment, not before it?
Java Services
What is a "fat JAR" in Spring Boot? How does it differ from a standard JAR?
Your server has 4 GB of RAM. Write the JVM flags you would use to set an appropriate heap size, enable G1GC, and activate the production Spring profile.
Write a systemd unit file for a Spring Boot JAR located at /opt/myapp/app.jar, running as the user myapp, loading environment variables from /etc/myapp/app.env.
.NET Services
What is the difference between a framework-dependent and a self-contained .NET deployment? When would you prefer each?
What is Kestrel, and why should you always put Nginx (or IIS) in front of it in production? Give two specific reasons.
Pick any technology from this part (Node.js, Python, Java, or .NET). Design a full deployment for a simple "Hello World" API on a single Ubuntu server, including: how to get the code onto the server, how to run the process, how to set up Nginx as a reverse proxy, how to set up SSL with Certbot, and how to ensure the process restarts on reboot. Write this as a step-by-step runbook.