Chapter 12: Technology Stacks — LAMP, LEMP, MEAN, MERN
Interview Questions
Practice by naming each stack’s roles, tracing the real request and explaining which result would verify the intended behavior. Treat listener, port and data choices as part of the deployment.
प्रत्येक stack मधल्या tools ची कामं सांगा, प्रत्यक्ष request चा मार्ग समजवा आणि अपेक्षित result कसा तपासाल ते सांगा. Listener, port आणि data यांची निवड deployment नुसार करा.
हर stack के tools का काम और असली request का रास्ता बताओ. अपेक्षित result कैसे जाँचोगे, यह समझाओ. Listener, port और data का चुनाव deployment के अनुसार करो.
- Q1. Expand LAMP, LEMP, MEAN and MERN.
- LAMP: Linux, Apache, MySQL, PHP. LEMP: Linux, Nginx, MySQL, PHP. MEAN: MongoDB, Express, Angular, Node.js. MERN: MongoDB, Express, React, Node.js.
- Q2. What is the difference between LAMP and LEMP?
- LEMP uses Nginx where LAMP uses Apache in these examples. Nginx commonly passes PHP requests to PHP-FPM with FastCGI. Apache can also use a configured PHP-FPM setup. Check the actual handler and routing.
- Q3. How is a React app deployed to production?
- For a static React project, build the reviewed browser artifact, verify the generated asset paths, and deploy it using the intended frontend. Keep appropriate browser fallbacks separate from assets and API routes. Server rendering can need another runtime.
- Q4. Why bind MongoDB to an intended private address or a local socket?
- Restrict reachability to the needed app and administrative paths. Configure the approved authentication, least-privilege roles and transport settings. Test the application’s intended access rather than exposing a database to the public.
- Q5. What is the role of Express in MERN?
- Express supplies routing and middleware inside Node.js. App code implements the HTTP API, validation and storage access. Mongoose is an optional ODM for MongoDB. JSON is a representation format, while REST describes architectural constraints.
- Q6. SQL vs NoSQL — when would you choose MongoDB?
- Compare access patterns, relationships, invariants, consistency and recovery. A document model can store data read together, while a relational model can enforce relationships and support joins. MongoDB also supports validation and transactions in supported deployments.
Make a first answer that you can defend with evidence
In a cloud support interview, the interviewer says the dairy wants to replace an existing pickup platform. The old site works. A new team likes another frontend and is wondering whether that means changing the database too. A simple answer might list four acronyms and choose one. A stronger answer asks what needs to change, what must remain compatible, and which tests would prove the customer can still do the work.
Use the same training case throughout. Mauli Dairy issues a receipt showing the collection point’s name when a booking was made. It also has a schedule screen that shows current pickup information. Today those two names match. Tomorrow the dairy may rename the place. A candidate that returns the right technology headers and JSON shape can still have the wrong business meaning. Your answer should be specific enough to tell the two views apart.
Answer each question aloud before opening the discussion. Give a short definition, apply it to the concrete case, and name what you would verify. Keep a distinction between your considered design and an observation you actually made. A small local lab later on gives you real response evidence to use while you rehearse. The services, data and hostnames in that lab are isolated training fixtures.
Explain what belongs in each stack
What do the four names mean, and do they prescribe an entire deployment?
In this chapter, LAMP uses Linux, Apache, MySQL or a compatible database, and PHP. LEMP uses Linux, Nginx, a compatible SQL database, and PHP. Nginx is commonly pronounced engine X, which explains the E. MEAN combines MongoDB, Express, Angular and Node.js. MERN has React in place of Angular. I would name the role of each part rather than presenting the acronyms as a list of mandatory deployment settings.
For example, the MEAN and MERN browser applications can call the same Express API. The public entry might be Nginx, a CDN and a load balancer, or another approved service. The application's technology choices do not specify the exact public ports, operating-system access method or default server. If the product needs SQL reporting while using React, it can use that combination even though the result does not fit the MERN acronym.
When the interviewer asks about request flow, I would draw the browser, named HTTPS endpoint, runtime and data path. Then I would mark which steps are active for a static file, for a server-rendered page, and for a data request. This establishes how to test the design. Naming all four technologies is useful background, but the work happens at the actual route and service boundaries.
What changes when you move a PHP application from Apache to Nginx?
The public runtime path and web routing configuration can change while the PHP application code and database stay compatible. Apache can run PHP through a suitable module or proxy to PHP-FPM. Nginx commonly sends appropriate dynamic requests through FastCGI to an independently configured PHP-FPM process. PHP-FPM is a manager for the PHP worker pool. It does not change the application’s language or the logical model used by its database.
I would inventory the current document root, rewrite and redirect behavior, public hostname, selected PHP handler and private access requirements. Nginx does not read an Apache .htaccess file. If the old site relies on directory-based rules, translate only the required behavior into the new arrangement. Pick a known permalink or PHP route to test along with an intended static file and a missing path. A welcome page returning 200 is weak evidence for the key operation.
If the static page works but PHP fails, compare actual script filename, permissions and FastCGI connectivity. The same PHP binary version in a login shell does not identify the serving pool or its extensions. Once the public route works, test the business result from the intended database and a separate control on a shared frontend. Keep a known compatible previous config for a scoped return.
How would you choose Angular or React for an existing API?
I would first define the browser requirements and contract with the existing API. Angular includes a framework and conventions for building web applications. React focuses on composing UI components and is often used with separate framework or routing choices. Both can support a browser-rendered UI, and their wider ecosystems can support other rendering approaches. A team using React can also use TypeScript. This decision is not simply JavaScript versus TypeScript.
Ask the team to build or review one representative customer action. Open a pickup route directly, navigate to it within the app, and observe successful and failed requests through the same API. Choose the setup the team can build, deliver, diagnose and maintain. If server rendering or static generation matters, add the actual deployment and freshness expectations to the comparison. Avoid promising lower cost or better speed from the name of a component alone.
I would not migrate the database just because the frontend changes. If the existing API already supplies correct fields, access and error semantics, both candidate interfaces can use it. Introduce a contract change only for a real requirement and coordinate compatibility with the previous client. Verify that an old or cached browser can continue through the supported transition window.
How does an architectural REST style differ from simply returning JSON?
JSON is a representation format. An HTTP endpoint can return JSON regardless of the broader application style. REST is an architectural style with constraints on the interaction between client and server, such as a uniform interface and stateless requests. In an interview I would be precise when describing actual behavior. I might say an Express service exposes an HTTP JSON API with routes that model resources, and then explain any REST properties it can support.
For the dairy, a GET for a booking normally retrieves its representation. The client needs the approved status, expected content type and fields that actually describe the booking. If a representation is absent, a defined error response can be part of the API contract. The contract also describes permitted inputs, meaning and circumstances for changes, not only whether its syntax looks like JSON.
Express exposes routing and middleware to help implement the API. A developer chooses how to parse, validate and authenticate requests and how to access storage. Mongoose is an object document mapper used by some applications with MongoDB. It is not required by Express and it is not the database server. Verify which driver or mapper does the work in the release you are operating.
Defend a database decision based on business rules
Would you choose relational or document storage for pickup bookings?
I would ask about the queries, updates, consistency, reporting and known data responsibilities. If the workflow uses separately managed customers and pickup locations with clear relationships and reporting across orders, a relational model can enforce useful keys and support joins. A foreign key can require a referenced record to exist when the engine and schema enforce it. Choose appropriate constraints and transaction boundaries for the actual invariants. Relational storage does not provide the right behavior if the schema omits the needed checks.
If the important read asks for a whole self-contained receipt, an embedded document may make it straightforward to store the original values and fetch them together. I would identify which values can safely be duplicated and which need separately maintained canonical data. MongoDB can validate document structure and supports multi-document transactions in appropriate deployments. NoSQL is a broad category. It does not tell me that there is no schema or that every update model is interchangeable.
I would ask the product owner what should happen when a collection point changes its name. The schedule should probably show the current name. A historical receipt might have to preserve the name displayed when issued. An SQL design can store snapshots and a document design can use references. The business meaning determines the model. Verify both views after a rename rather than benchmarking two unrelated queries and guessing about correctness.
What is the point of making a database private if it already requires a password?
Reachability and authentication are separate controls. The app needs access to its specific data endpoint and authorized operations. A browser customer does not need to contact the database directly. Constrain allowed sources and listen interfaces to the planned architecture. Authenticate the app with a dedicated identity and choose the expected transport protection. Restrict roles to the actual required operations and store secrets in the appropriate server-side system.
For a single-host lab, a loopback bind or Unix socket can restrict network reachability to that host. On separated services, a private address reachable from the approved application path may be necessary. MongoDB’s configuration and supported packaging can provide different chosen settings. Verify which interfaces the actual service listens on, and check the network access and authentication policy in effect. Do not make a public route a permanent part of the design just to connect from a workstation.
Backup and restore still matter even with protected access. Rehearse a representative read and write after a planned restoration. If the app receives read errors, compare its actual network path, transport, auth and authorization instead of treating any administrative login as proof. The app can connect without having permission to read or change the data required by that particular route.
What changes when sessions move from worker memory to Redis?
If a login session exists only in one worker’s memory, another process may not recognize the next request. Replacing that worker can also discard the session. An appropriately shared session store can make the necessary records accessible to eligible instances. Redis can serve that role under an intentional expiry, authentication, memory, availability and persistence policy. A load balancer’s affinity can influence where traffic goes, but it cannot replicate a process’s memory.
Classify the data first. A login session may be allowed to expire or require the user to sign in again. An accepted booking and attendant payment state may require different durability, backup and recovery guarantees. Redis supports several persistence options or can run without persistence, depending on the required behavior. Availability replicas and persistence solve different parts of the problem. I would test failure and expiry, not only show that two workers can read one key.
A shared state system is one option. Some app designs use appropriately validated self-contained tokens, with different security and lifecycle trade-offs. I would discuss what happens to a session and a saved booking when worker A is replaced by B. The expected outcome needs an observed operation. A healthy request distribution graph does not prove that users’ actual state is intact.
Explain frontend delivery and runtime supervision
Why can a server deliver a React site directly and still forward its API elsewhere?
A browser-oriented React build can produce static HTML, JavaScript and CSS. A CDN or web server can return those files without running an application handler on each request. A separate Express API can be a running Node process that validates requests, reads storage and generates JSON. A reverse proxy can forward the API prefix to its private listener. This is one deployment pattern. React frameworks with server rendering may require another runtime path, and a hosting platform can integrate these responsibilities differently.
Write the intended URLs for both. The entry and assets should have expected versions and content types. The data route should return an expected status and body for both valid and invalid operations. A common mistake is judging the API from the success of the shell. If the API gives HTML because a generic fallback selected the browser document, the route does not fulfill what the data client expected. Verify the private API independently and compare the actual named public request.
When asked if using one public hostname removes all security concerns, I would separate origin and authorization. The browser’s origin involves its scheme, host and port. A same-origin setup can avoid a deliberate cross-origin request policy for this workflow. The app still needs sound authentication, authorization and safe handling of input. A routed path by itself is not an access decision for a user or database.
Is npm start always a development server?
The command runs project-defined start behavior or npm’s supported default behavior. It might run a development watcher or run an intended production process. Read the actual package scripts and deployment documentation. Check which build produces the approved output and which production runtime, if any, serves it. An Angular development server is meant for development. Many static app releases are delivered by a web server independently of the build tool, while a server-rendered framework can need an approved application server after building.
For a candidate release, record the Node version, lockfile and selected build configuration. Inspect deployed output and its generated references. Do not assume the correct public folder is always named dist or contains only the same files across projects. An appropriate fresh workspace lets you build a complete artifact without replacing a running service’s dependencies. Test the resulting entry and assets at their actual public path before switching customers to it.
If the interview asks whether a small EC2 instance can build the app, check the measured memory and resource needs, time and constraints of the real build. It might work locally or in CI and be unnecessary on production. An out-of-memory kill has a different fix from a missing module or incompatible runtime. Decide where to build based on evidence, not on a package command’s name.
What does try_files do, and what should it not catch?
Within a matching Nginx location, try_files checks configured file or directory candidates under the applicable mapping. Its final parameter controls what happens when a candidate does not exist. That can be an internal redirect to an entry document or an error code. For a client-side browser route, serving a suitable beginning document lets the runtime router interpret the requested path. It does not automatically apply the correct rules for every incoming URL.
In a split UI and API deployment, keep the API and required static assets separate. An unknown API should return the appropriate API error, and a missing JavaScript file should be diagnosable as missing. A broad fallback that returns HTML for them, even with status 200, can confuse a client expecting JSON or script. In a PHP site, a different route design can intentionally run a PHP entry script, relying on the configured connection to the worker. Match the fallback to the intended kind of request.
I would test a valid deep link, a current asset, an intentionally missing asset, a valid API and a deliberately unknown API. Preserve response status, media type and a safe marker. If the public test disagrees with a direct app request, inspect the selected named vhost and location. If a reverse proxy rewrites the path or changes the prefix, confirm the private application saw the route its code actually registers.
What does each of PM2, systemd and Gunicorn supervise?
PM2 can manage selected Node application processes and help with restart, logging and optional startup integration according to configuration. systemd can supervise a Linux service and define its identity, working directory and restart policy. Gunicorn is a Python WSGI server with a master process that manages workers. It can replace a failed worker while a separate manager supervises the overall Gunicorn service. These tools occupy different layers and are not a single interchangeable class of public web server.
The phrase “starts at boot” needs the actual startup design. For PM2, the chosen identity, approved startup integration and saved process list have to agree. For systemd, the effective unit configuration and startup relationships matter. A process running in the developer’s shell or listed in another supervisor’s context does not establish what returns after reboot. I would verify the actual app marker and route in a separately approved rehearsal.
A manager saying the process is online tells me about lifecycle. A readiness test can ask whether the app is available to accept the intended traffic. A representative operation can show whether relevant data and routing agree. These checks have different jobs. An ordinary manager restart does not prove a cluster reload is interruption free or demonstrate the behavior of a previously accepted operation during a transition.
Compare migration options with explicit service boundaries
How would you move a static frontend and Express API off one EC2 instance?
I would first ask whether the frontend is a static build or needs its own server runtime. For a truly static artifact, an appropriately configured origin and delivery service, such as Amazon S3 with CloudFront, can be one option. The routing design must preserve expected browser deep links, asset paths, access settings and API behavior. A server-rendered application can need a different runtime and resource model. Move only the part whose deployment requirements you understand.
For the Node API, AWS Elastic Beanstalk on an appropriate supported platform or a container service such as Amazon ECS can be candidates. Compare how each option starts and health-checks the app, forwards traffic, configures identities and resources, exposes logs and supports rollback. Manage the private data path separately. Managed infrastructure still leaves the team responsible for its application, security configuration, release compatibility and operations appropriate to that service.
I would write two diagrams, one for today and one for the candidate. Each identifies build artifacts, public entry and certificate, API runtime, private data endpoint, secrets access and observability. The change plan must say what continues to serve old clients, how to test app and database migration without breaking data, what will count as correct, and which owner can reverse the affected part. Avoid treating all services that run containers as identical or requiring a specific architecture without a reason.
Can a MongoDB-compatible service be assumed to run all existing queries identically?
Compatibility is a scope claim to verify, not a guarantee from an identical-looking connection string. I would inventory actual driver versions, wire behavior, supported query and aggregation operators, schema and index usage, transaction and read and write requirements, and backup and restore tools. For example, the AWS documentation lists functional differences between Amazon DocumentDB and MongoDB. Check the selected service and version against the actual app, rather than treating every compatibility statement as full parity.
Test with an approved staging copy and representative request classes. A quick successful connection and list operation can miss unsupported behavior in reporting, schema transitions or write transaction options. Compare returned values, ordering assumptions and data behavior under updates. Test secret delivery and transport from the app under its real identity. Then verify migration, realistic failure modes and access without opening an unnecessary public database path.
For the dairy, check current schedule and historical receipt behavior after a rename. Either service might store the data successfully and return JSON. The requirement matters when selecting the migration mapping. Record which part is an app schema design question and which part depends on the database engine. If one operation is incompatible, discuss an application change or a different supported service instead of silently assuming it will work later.
What would you choose for an internal banking or administrative app?
I would ask about the data and security requirements, internal availability, transaction semantics, reporting, audit obligations, deployment environment and skills. A framework team’s experience and maturity of supported tooling can influence the choice. Neither the word banking nor the word internal establishes a specific vendor or database. A realistic interview response states the conditions under which a relational design, certain service policies and an application framework could fit.
For example, a reporting service may need consistent snapshots and relationship queries. A public content site may prioritize easy editing and delivery. A controlled forms app may require defined identities with restricted access and retention. In each case I would list critical operations and choose a supported stack or managed arrangement that can implement them. Confirm who will perform patches, respond to alerts and test restore. An apparently simple proof of concept does not establish day-to-day operations.
Do not infer public IP or port rules from the organization’s name. Draw the actual controlled access paths and describe which roles need entry. Validate least-privilege access and audit evidence in an approved test. State a representative business example, such as recording an approved adjustment once with an auditable result. Demonstrate that requirement independently of what framework was used.
Answer a failure scenario without changing several layers
A browser reload works but the data response is HTML. Where do you check?
Keep the exact named browser URL and the separate request for data. Inspect the observed status, Content-Type and harmless body marker. Loading a browser entry route says little about the API path. If the data request receives HTML, compare the public routing and fallback with the backend’s expected path. A server-side miss hidden by the frontend is a different symptom from the API’s own JSON 404 or 503.
Find whether the frontend mapped the request to the app’s private route and whether the app received it. The vhost or prefix selection might be wrong, or the backend might receive a rewritten URI. Test the same method and path privately where permitted, then repeat the intended ordinary named request. Keep the original HTML control so you can verify any correction does not break recognized browser navigation. Do not make a public database rule just because the frontend supplied a wrong representation.
Would comparing public load tests alone tell you which data model is correct?
A timing comparison can test a known workload under documented assumptions. It cannot decide what a field should represent. Choose the expected current state and history first, then run consistent operations with representative data, indexes, security controls and failure cases. A detailed metric must still correspond to a useful result. A fast response with an inaccurate receipt can score well on duration and fail the requirement.
Use equally relevant operations for comparison. Record successful operations, measured cost or resource use, incorrect results and errors. Verify the same state after dependent updates and after restore. If an API serves both original receipts and current directions, distinguish the two representations explicitly. Test which becomes visible before and after a rename. The correct stack should support the behavior the customer needs even if another design had an attractive isolated response time.
How do you know you can roll back a frontend and API independently?
I would map the versions that can talk to each other, then check how requests and stored data evolve. A returning browser might still use an earlier cached bundle, even after the new API is live. The earlier bundle may expect a field to have the old meaning. A database upgrade might also make earlier backend code incompatible with new writes. Independent artifacts help with staging only when the actual contracts support the transition.
Test the current browser and API pair as a baseline. Then exercise the candidate browser with the intended API and an earlier supported browser with the new API. Use a meaningful route such as current pickup or an issued confirmation, plus a deliberate failure. Verify that a temporary return to the previous artifact still supports the required data. If it does not, agree on a forward fix or a data recovery plan before deployment. When a user ticket names a route, you want to identify which pair they actually saw.
I would keep complete prior build assets available for the approved window and document a safe rollback point. State which release and data version are being restored. Otherwise a rollback can change the files visible on disk while leaving the application unable to produce the promised response.
What can you infer if one worker successfully reads a session after another worker stops?
It establishes the result for that session and those paths during the observed test. A shared store may have made the session available. A self-contained token design could also let a second worker validate the request without using a shared lookup. Identify which design actually produced the result. The existence of two working requests does not by itself establish the lifetime, expiry or recovery behavior of all sessions.
Make a deliberate test vary the right component. Verify a permitted request through one worker, then through another, and use a test session with known expiry or removal conditions. If the requirement involves failure of the shared store, test the expected behavior of the application when that store is unavailable. Some products require signing in again. Others have more stringent availability demands. Do not put long-lived business records in a session simply because the second worker could read it.
Report the scope and operating assumptions. Separate app-worker replacement, data-store replacement, and any break in access to the store. Determine whether the intended persistence and backup configuration meets the required data-loss window. The same tool can be used for different goals, so a recognizable product name is not the recovery evidence.
What would you compare before adding another private port rule?
I would identify the failing connection by source, destination and intended protocol. Determine whether the application is actually listening at that address and whether the path is a Unix socket, loopback or between separate services. For a socket on one machine, filesystem permissions can be relevant. For a cross-network connection, the associated security groups and routes matter. A public web listener and a private database listener usually serve separate audiences.
If a public frontend succeeds and its app cannot read data, inspect the observed application error and the correct private path rather than exposing an unrelated interface. Confirm that access policy, credentials and transport all apply to the actual service account. Close the diagnosis with an ordinary useful request using the approved architecture. A successful connection made with a privileged identity through a new broad route does not prove that the production application now meets its intended access and operation requirements.
Prove that matching JSON shapes can hide different meaning
Use Python 3 in a regular local environment with its SQLite module. The file-backed SQLite data store enforces a foreign key and provides a current lookup through a join. A tiny JSON file represents an intentionally retained receipt snapshot. Python’s built-in HTTP server exposes them as two simulated views under separate reserved Host values. Real HTTP requests and SQL statements run locally. The JSON file is a document-model example, not an installation of MongoDB or a comparison of database performance.
Predict the outcome for the same initial booking from both views. The response should have the same HTTP status, Content-Type and JSON fields. Then predict what happens when the canonical pickup name changes while the already-issued receipt remains. Also predict whether a booking can be inserted into the SQLite table with a reference to a nonexistent pickup point, and which evidence should show what happens to an unknown booking.
python3 - <<'PY'
from contextlib import closing
from http.client import HTTPConnection
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
import json
from pathlib import Path
import sqlite3
from tempfile import TemporaryDirectory
from threading import Thread
rows_host = "rows.example.test"
docs_host = "docs.example.test"
route = "/api/bookings/TRAIN-1"
class Contract(BaseHTTPRequestHandler):
def do_GET(self):
response = None
host = self.headers.get("Host")
if self.path == route and host == rows_host:
with closing(sqlite3.connect(database)) as db:
row = db.execute("""
SELECT b.code, p.name, b.time
FROM bookings b JOIN pickup_points p ON p.id = b.point_id
WHERE b.code = ?
""", ("TRAIN-1",)).fetchone()
if row is not None:
response = dict(zip(("booking", "pickup", "time"), row))
elif self.path == route and host == docs_host:
response = json.loads(document.read_text())["receipt"]
status = 200 if response else 404
body = json.dumps(response or {"error": "unknown booking"}).encode()
self.send_response(status)
self.send_header("Content-Type", "application/json")
self.send_header("Content-Length", str(len(body)))
self.end_headers()
self.wfile.write(body)
def log_message(self, *args):
pass
def request(host, path):
connection = HTTPConnection("127.0.0.1", server.server_port, timeout=2)
try:
connection.request("GET", path, headers={"Host": host})
result = connection.getresponse()
return result.status, result.getheader("Content-Type"), json.loads(result.read())
finally:
connection.close()
with TemporaryDirectory(prefix="stack-interview-") as folder:
lab = Path(folder)
database = lab / "orders.sqlite"
document = lab / "receipt.json"
original = {"booking": "TRAIN-1", "pickup": "East Counter", "time": "16:00"}
document.write_text(json.dumps({"receipt": original}))
with closing(sqlite3.connect(database)) as db:
db.execute("PRAGMA foreign_keys = ON")
db.executescript("""
CREATE TABLE pickup_points (id INTEGER PRIMARY KEY, name TEXT NOT NULL);
CREATE TABLE bookings (
code TEXT PRIMARY KEY,
point_id INTEGER NOT NULL REFERENCES pickup_points(id),
time TEXT NOT NULL
);
INSERT INTO pickup_points VALUES (1, 'East Counter');
INSERT INTO bookings VALUES ('TRAIN-1', 1, '16:00');
""")
try:
with db:
db.execute("INSERT INTO bookings VALUES (?, ?, ?)", ("BAD", 999, "16:00"))
except sqlite3.IntegrityError:
pass
else:
raise AssertionError("A new booking referenced a missing pickup point.")
assert db.execute("SELECT COUNT(*) FROM bookings").fetchone() == (1,)
with ThreadingHTTPServer(("127.0.0.1", 0), Contract) as server:
thread = Thread(target=server.serve_forever, daemon=True)
thread.start()
try:
wanted = (200, "application/json", original)
assert request(rows_host, route) == wanted
assert request(docs_host, route) == wanted
assert request(rows_host, "/api/bookings/OTHER") == (
404, "application/json", {"error": "unknown booking"}
)
print("Both views agreed before the name change. Unknown booking returned JSON 404.")
with closing(sqlite3.connect(database)) as db, db:
db.execute("UPDATE pickup_points SET name = ? WHERE id = ?", ("East Hall", 1))
current = dict(original, pickup="East Hall")
assert request(rows_host, route) == (200, "application/json", current)
assert request(docs_host, route) == wanted
print("Current lookup returned East Hall. The issued receipt still said East Counter.")
print("The existing API shape alone did not prove equivalent meaning.")
finally:
server.shutdown()
thread.join(timeout=5)
assert not thread.is_alive() and not lab.exists()
print("Private listener and synthetic data removed.")
PY
Look for the printed result that both views initially agreed. The database enforcement check already rejected the made-up booking that pointed to a missing location, and only the original row remains. The HTTP test also observes JSON 404 for an intentionally unknown booking. These are different checks. The first tests a database relationship on the private fixture. The second tests how the application represents missing resources for its caller.
After the rename, the current SQL lookup returns East Hall while the stored receipt still says East Counter. Both return 200 and the same fields. Their useful meanings diverge. If the route is meant to represent current pickup information, the current name is correct. If it is meant to show what was printed on an issued receipt, the old name can be correct. Choose the requirement and name the API representation before swapping backends. Either database family can represent both views when deliberately designed to do it.
The cleanup shuts down the local listener, joins its serving thread and verifies the temporary data directory is gone. No real order is altered. If the lab fails before the assertions, check Python’s SQLite module and whether local loopback requests are permitted. A SQL error in this fixture is only a result for this isolated engine and schema. The prior chapter’s MongoDB and MySQL lessons provide additional engine-specific practice.
In a mock interview, explain the lab in three sentences. Start with the data invariant, then state the measured response difference, and identify the chosen meaning of each endpoint. Ask a partner how the design would change if all old receipts must display current directions without losing the original printed name. This follow-up calls for explicitly representing two different values rather than picking whichever technology happened to produce one of them first.
Make the example survive a follow-up question
Write a one-page operating note for the two API views. Give their exact private and public request routes, which storage identity can read each one, and the expected response before and after a controlled rename. Add a browser acceptance check if the data supports a desk interface. The entry should use the correct assets, the useful operation should distinguish current and historical values, and an unknown booking should get its own expected result. Include which access conditions and versioned artifacts you would need to test in a real deployment.
Ask one partner to choose a changed requirement. They can introduce a second pickup location, require a restore from backup, or need an earlier browser version to stay usable during a migration. Explain which behavior needs a separate check. A renamed pickup location is a content change. A removed old JavaScript bundle affects delivery. A lost data record affects storage and recovery. A deployment that keeps those responsibilities visible makes failures easier to narrow down.
For a last rehearsal, ask which tests would remain valid if the team moved the browser site from Nginx to an approved managed delivery service. The current and historical data behavior still matters. Browser routes, asset caching and public access policies may need different tests. The API runtime and data store can stay the same if that change is truly scoped to the frontend. Write which verification claims you retain and which you have to test again.
Answer the short follow-ups with a concrete result
A current-name lookup and an old receipt both return JSON 200. What would prove one has the wrong content?
Answer and reasoning
Compare the actual field to the required view after a rename. The useful expected value depends on whether it represents current directions or the name at issue time.
Should the front-end tool be chosen before learning whether the data model needs current and historical views?
Answer and reasoning
Identify required reads and changes first. Both interface options can consume a documented API. The backend needs to represent each meaning correctly, regardless of the UI framework.
An unknown API route returns the browser shell. Which output is missing?
Answer and reasoning
The API’s specified error response. Test that the intended API prefix reaches its private route instead of falling through to browser HTML.
What does a database connection succeeding tell you about a managed migration?
Answer and reasoning
It verifies a connection under the tested conditions. It does not verify all operators, transactions, ordering, data meaning, authorization or recovery. Test the actual application operations.
Why can changing one process’s restart policy leave a public application unavailable?
Answer and reasoning
The configured process may restart successfully while its data dependency, private listener or named frontend still fails. Check the intended operation and its route after the process result.
Cards for interview review
Role before acronym
Name the browser, public route, serving runtime and storage. Explain which components participate in the request you tested.
Representation and meaning
A 200 JSON response must still carry the correct data for the required operation. Test a change that distinguishes current state from historical snapshots.
Frontend boundaries
Write expected content types and status for entry, assets and API. Preserve distinct errors for unsupported paths.
State after process replacement
Classify session and business data. Verify the actual durable and shared state the chosen deployment promises.
Managed responsibility
Know which tasks the service performs. Keep explicit app compatibility, data protection, authorization and rollback tests.
Official references
- Apache virtual host behavior
- Nginx file checks and fallback
- Nginx FastCGI and PHP routing
- Angular framework and rendering options
- React delivery and framework choices
- Fielding’s REST architectural style
- Express application routes
- npm start script semantics
- PM2 startup and saved process state
- Gunicorn process and worker architecture
- systemd service management
- SQLite foreign key enforcement
- MongoDB data modeling
- MongoDB transactions
- MongoDB security checklist
- Redis persistence trade-offs
- AWS Elastic Beanstalk deployment responsibilities
- Amazon ECS container orchestration
- Amazon DocumentDB and MongoDB functional differences
Quick revision cards
Revise this lesson in two minutes. Save the cards on your phone or download them as PNG files. The QR code on each card opens its lesson.

More cards: Ravi Sir's Cards.