I would go the 4x4's in pressure treated as my first choice if going wood. This wood is so much harder and will actually last longer, then you can go with your cedar for the slats and even rails.
But, I nowadays, almost 75% of the time use metal round posts with metal fasteners. seems to last much longer and will not lean as much. Go down a minimum of 2 feet and then fill the inside of the post also with cement and cap it off.
Secondly, I always use pressure treated 2x4's for my rails. I cut the lumber at an angle and attach the rails with the angle on top this tends to shed the water better and prohibits kids from climbing on the rails since they are at an angle.