Layer 4 load balancers work at the transport layer, using IP addresses and ports to forward traffic without looking at the content. Layer 7 load balancers operate at the application layer, inspecting data like HTTP headers or cookies to make smarter routing decisions.
Routing based on URL paths and user sessions requires inspecting application data, which Layer 7 load balancers can do. Layer 4 load balancers cannot inspect URLs or cookies.
Layer 4 load balancers handle traffic based on IP and port, requiring minimal processing, so they scale well under heavy load. Layer 7 load balancers inspect application data, which is more CPU intensive and can limit scaling.
Layer 4 load balancers are faster because they only look at IP and port, but they cannot make decisions based on application data. Layer 7 load balancers can route based on detailed information but add processing overhead and latency.
10,000 requests/second * 0.1 ms/request = 1,000 ms = 1 second of CPU time per second.