It scales just fine because transactions that aren't going to be mined in a reasonable amount of time don't need to get into the mempool at all. This is precisely why there is a mempool size limit, along with code that automatically adjusts the minimum relay fee based on what transactions got ejected due to that size limit.