tags : HTTP, Networking, Subnetting, Load Balancers, Web Performance, Network Programming
The case of 0.0.0.0 & Localhost
What about 127.0.0.1
127.0.0.1 is normally the IP address assigned to the “loopback” or local-only interface.
Multiple meanings of 0.0.0.0
Meaning of 0.0.0.0
is contextual.
non-routable meta-address used to designate an invalid, unknown, or non-applicable target
- Route entry
- Usually means the default route.
- Webserver
- 0.0.0.0 means all IPv4 addresses on the local machine.
- Listen on every available network interface
- This explicitly limits the listening daemon to IPv4 for no good reason.
- DHCP Used as source IP by clients during DHCP.
FAQ
Sockets and Connections
- A connection (See HTTP) does not occupy a
port
. - The only hard limit for connections the number of open file descriptors on the server. But performance can degrade by CPU bound/ io bound operations.
- Every connection creates a new
socket
. Some operating systems let you load balance incoming connections between multiple sockets.
How does a web sever handle incoming requests?
- A webserver usually has 1 listening socket.
- But “accepting” the connection duplicates that socket and sets the remote IP and port on the copy.
- So in most cases, no. of connections = no. of active sockets
- I am not sure how it works in the case of UDP.
Resources
TODO Writing a fast server
- How many concurrent TCP connections
- The C10K problem
- The Secret to 10 Million Concurrent Connections -The Kernel is the Problem
- fast-servers
- Fast UNIX Servers - dankwiki, the wiki of nick black
- djabberd: c10k? hah! - brad’s life — LiveJournal
- Advanced Napkin Math: Estimating Systems
- https://github.com/sirupsen/napkin-math
- Simon Eskildsen - Sirupsen
- Increase HTTP Performance by Fitting In the Initial TCP Slow Start Window
- How much memory do you need to run 1M concurrent tasks? | Hacker News