This is not so easy. Infact it seems almost impossible to be done in an elegant way. While the capacity of public channels is known to everyone on the network the balance of each channel is unknown.
As nodes sharing their balance is
- a privacy issue,
- technically in a peer-to-peer network difficult as the channel state / balance might change several times per second and gossip protocol propagation takes longer and
- Hard to proof validity of a published the channel Ballance
We usually don't know the balance.
Thus a Sender could just use try and error which is particularly inefficient in large networks as the number of paths grows quite quickly.
In practice node operators could use "manipulated onions" to probe nodes for a current minimal channel balance. Which obviously is also difficult as the balance might change quickly.
In precise people work on AMP routing which means doing several small payments (maybe even over several paths) instead of a large one or JIT routing which allows nodes along a path to rebalance their channels if they don't have enough balance to forward the onion. (disclaimer I proposed JIT routing and it is not clear yet if it becomes a lightning standard)
On a Side note :maybe you want to add my youtube channel with lightning educating to your mega thread (which in the past helped me a lot! Thanks!)