0
0
PHPprogramming~5 mins

Comparison with long-running servers (Node.js) in PHP - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a key difference between PHP and Node.js in how they handle server requests?
PHP creates a new process for each request, while Node.js runs a single long-running process that handles many requests asynchronously.
Click to reveal answer
intermediate
Why does Node.js use an event-driven model for handling requests?
Node.js uses an event-driven model to efficiently handle many requests without waiting for each to finish, improving performance for I/O tasks.
Click to reveal answer
intermediate
How does PHP's request lifecycle affect memory usage compared to Node.js?
PHP frees memory after each request ends because it starts fresh every time, while Node.js keeps memory in use as it runs continuously.
Click to reveal answer
beginner
What is one advantage of PHP's short-lived process model?
It isolates each request, so errors or memory leaks in one request do not affect others.
Click to reveal answer
intermediate
What challenge might arise from Node.js's long-running server approach?
Memory leaks or bugs can accumulate over time since the server process stays alive, requiring careful management.
Click to reveal answer
How does PHP handle each incoming web request?
AUses a single long-running process
BStarts a new process for each request
CHandles requests asynchronously in one process
DQueues requests and processes them one by one
What is a benefit of Node.js's event-driven model?
AIt handles many requests efficiently without waiting
BIt blocks other requests until one finishes
CIt creates a new process for each request
DIt uses more memory per request
Which server model isolates errors per request better?
ANode.js long-running process
BBoth are equal
CNeither isolates errors
DPHP short-lived process
What is a potential downside of Node.js's long-running server?
AIt restarts after every request
BIt uses less memory overall
CIt can accumulate memory leaks over time
DIt cannot handle asynchronous tasks
Which technology is more likely to free memory after each request?
APHP
BNeither frees memory
CBoth free memory continuously
DNode.js
Explain how PHP and Node.js differ in handling web server requests and the impact on memory management.
Think about how each handles requests and what happens to memory after.
You got /4 concepts.
    Describe one advantage and one challenge of using a long-running server like Node.js compared to PHP's model.
    Consider performance and maintenance aspects.
    You got /2 concepts.