0
0
Nginxdevops~5 mins

sendfile and tcp_nopush in Nginx - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the sendfile directive do in nginx?
The sendfile directive enables nginx to use the operating system's sendfile() system call to transfer files directly from disk to the network socket, improving performance by avoiding copying data between user space and kernel space.
Click to reveal answer
beginner
What is the purpose of the tcp_nopush directive in nginx?
The tcp_nopush directive controls how nginx sends TCP packets. When enabled, it delays sending partial packets to send larger packets at once, reducing overhead and improving network efficiency.
Click to reveal answer
intermediate
How do sendfile and tcp_nopush work together in nginx?
When sendfile is enabled, tcp_nopush helps by delaying packet sending until a full packet is ready. This combination improves file transfer speed and reduces CPU usage.
Click to reveal answer
beginner
How do you enable sendfile and tcp_nopush in nginx configuration?
In the nginx configuration file, add these lines inside the http block:<br>
sendfile on;
tcp_nopush on;
Click to reveal answer
beginner
What is a real-life analogy for sendfile and tcp_nopush working together?
Imagine sending a big package by mail. sendfile is like using a direct conveyor belt to move the package without extra handling. tcp_nopush is like waiting to fill the box completely before sealing it, so fewer boxes are sent and shipping is efficient.
Click to reveal answer
What does enabling sendfile in nginx do?
ACaches files in memory
BCompresses files before sending
CEncrypts network traffic
DTransfers files directly from disk to network socket
What is the effect of enabling tcp_nopush in nginx?
AForces immediate sending of all packets
BDelays sending partial TCP packets to send larger packets
CDisables TCP connections
DSplits packets into smaller pieces
Which nginx block typically contains sendfile on; and tcp_nopush on; directives?
Ahttp
Bserver
Clocation
Devents
What is a benefit of using sendfile with tcp_nopush?
ABetter logging of requests
BIncreased file encryption
CImproved file transfer speed and reduced CPU usage
DAutomatic file compression
If sendfile is off, what happens?
AFiles are copied through user space before sending
BFiles are sent directly from disk
CNetwork connections are closed
DFiles are compressed automatically
Explain how sendfile and tcp_nopush improve nginx performance when serving static files.
Think about how data moves from disk to network and how packets are sent.
You got /3 concepts.
    Describe how to enable sendfile and tcp_nopush in nginx and where to place these directives.
    Consider nginx configuration structure and applying global settings.
    You got /3 concepts.