Sadly, I have done red-eyes a lot in my career.
I use 5 mg of zaleplan when I board so that i can go to sleep soon after takeoff. This seems to work better than Ambien although they are in the same class of sleeping medication. Alternatively, you can drink half a bottle of Dreamwater, which also seems to do the trick - of knocking me out.
The problem with medications is that if you have to deplane for any reason (eg. medical emergency), you will be groggy and may fall asleep while waiting for the plane to reboard. THAT has happened to me.