The layer number is about what it may read
The layer number tells you how much of your request the balancer is allowed to read.
A layer 4 balancer works down at the transport level. It sees addresses and port numbers, and forwards your connection without ever looking inside it. A layer 7 balancer opens the HTTP request, reads it, and routes on anything it finds: the path, the hostname, a cookie.
Being blind is what makes layer 4 fast. It does almost no work per packet, so it pushes enormous volume at low and very predictable latency. That is why the raw network balancers from AWS and Google live down there, handling millions of packets a second per machine.
It is also your only choice for traffic that is not HTTP, like a database connection or the UDP that game servers and DNS run on.
Layer 7, and what it costs
Reading the request is what makes layer 7 worth the money. One balancer sends /api to your API machines and /static to your file servers. It splits traffic 95 to 5 between the current release and a new one you are testing, retries a failed request against a different machine, and terminates HTTPS.
You pay for that in processor time per request and a little latency, plus more code that can break or be attacked. Parsing anything a stranger sent you is exactly where security holes live.
Large sites run both. A layer 4 tier out front soaks up raw connection volume and spreads it over a fleet of layer 7 proxies that do the clever routing. That shape sits in front of most of the internet, whichever products fill the two slots.
For the interview, default to layer 7 for a web API, because the routing rules and safe releases earn their keep. Say layer 4 when you need raw TCP, UDP, or connection counts in the millions.
Worked example
Petra's team ships a rewritten checkout service and refuses to big-bang it. Their ALB rule splits traffic by weight: 95 percent to the checkout-v1 target group, 5 percent to v2. Eleven minutes in, the dashboard shows v2's error rate at 2.1 percent against v1's baseline of 0.1 percent, a null pointer on a gift card path nobody tested. Petra flips the weight back to 100/0; total exposure was about 3,000 requests and 60 failed checkouts, all retried successfully on v1. The postmortem's one-liner: an L4 balancer could not have done this, because splitting by percentage per HTTP request and matching only /checkout requires reading the request. The gift card fix ships the next week, again at 5 percent first.