If you are visiting San Francisco and think you might want to visit Alcatraz, then it is a very good idea, in fact a MUST, to book your tickets months in advance before you leave home. Alcatraz is a very popular tour and almost impossible to get a ticket on short notice.
In general, anyone travelling to California during the summer months would be well-advised to book their hotels and resort tickets (Disneyland, Universal Studios, Hearst Castle, Alcatraz, etc. months in advance), especially if you are planning to be at these places on the weekend.
Same applies to Las Vegas during the fall or springtime, especially on the weekend. And in this case, airfare to Las Vegas also books up early, especially for the cheap fares (Southwest Airlines, Jet Blue, and US Air).
When I visited Alcatraz we walked up and just bought a ticket for the next boat. So I don't know about"months in advance" more like minutes in advance.