Hi, this is a question that has been on my mind for a while. A view that's pretty common is that Lightning can theoretically scale infinitely (more nodes means more routes, better hardware means more transactions can be processed per second, etc).
The way a Lightning payment works is something like this:
Suppose Alice wishes to pay Carol 1.0BTC through intermediate routing node Bob. Carol generates a secret r, and shares hash(r) with Alice. Alice offers Bob a payment of 1.0 BTC (+ fees) if he can provide the secret r. This is represented as a hash time-locked contract, where Bob can claim the funds if he provides the secret. After a certain timeout though, Alice can claim the funds back.
Bob then creates a new output on the Bob-Carol channel that transfers Carol the 1.0 BTC if she provides the secret r, again with a timelock.
Right now both channels have 3 outputs, the first one has one output for Alice (subtract 1.01 BTC), one for Bob, and the 1.01BTC Hash-timelocked contract. Once the payment has been completed (or expired), this output can be consolidated back again into just 2 outputs representing the balances of each channel participant.
If however, Alice for example becomes unresponsive and refuses to consolidate, Bob has no choice but to unilaterally close the channel, and claim the funds by providing the secret.
How many HTLCs can Bob have at once? Each Lightning Node decides this on their own, but the maximum is 483, because any transaction with more than this # of outputs won't be considered a standard BTC transaction and can't be relayed. This means that at most, each channel can have 483 outstanding payments at any time.
A few years ago, some researchers demonstrated a flood & loot attack on Lightning. If I understand correctly, they generated a large amount of payments after opening channels, and then never completed the payment. Doing this they were able to lock up a large amount of liquidity on the network and forced nodes to force-close their channels. However, if the network is too congested, then it's possible they can't claim the HTLC by providing the secret before the timelock expires (Remember, once the timelock expires, Alice can claim her 1.01 BTC back!). This also allowed them to steal funds from nodes on their simulated network.
However this raises a question. Even without such a malicious attack, isn't it possible that with millions of users, the throughput wouldn't be able to keep up? Depending on your network latency/processing speed, it can take several seconds to settle an HTLC, now multiply that by millions of users. There's also a finite amount of BTC, so there's a limit on how many channels you could even have in total across the entire network.
OP_VAULT might help increase throughput, you could represent all your HTLCs as a "tree" of transactions inside a single output, and then settle them across multiple blocks which would allow you to raise the HTLC limit (see: https://utxos.org/uses/htlcs/). But how much would it really help? What's the actual theoretical maximum TPS of Lightning
Did I get something wrong? Comments are greatly appreciated