2 hours is tight, I always find int-int or int-dom in Miami stressful. There are agents who manage the queue and direct those with tight connections to the express connections CBP channel, but it can be moving very slowly anyway. I can totally see a scenario in which your flight arrives 15 minutes late, then waits another 15 minutes on the tarmac "because there's another aircraft parked at our gate", then a long-ish walk to the CBP area which is completely backed up; you finally make it through just to realize you need to wait in another massive queue to re-clear security. I'd recommend around 3-3.5 hours. The AA flagship lounge is very nice and has good food, so if things go quicker than expected, you can kill some time there. The Amex lounge is also nice, with limited but tasty and healthy food options (at least by US standards), although it can get super crowded.