Istanbul, being a huge city, suffers from the traffic many hours during the day. This is why you should leave your hotel, soon enough in order to catch your flight without having any problem.
The regulations say that the travelers must be at the airport at least 1,5 hours before the flight…So:
--If your hotel is located in Sultanahmet area, you should leave your hotel 2,5 hours prior to your flight. (the distance is almost 20km)
--If you hotel is located in Taksim area, you should leave your hotel 3 hours prior to your flight. (the distance is almost 25km)