At least 32 people were killed in a suicide attack carried out by al-Shabab militants at a popular beachfront location in the Somali capital, a police spokesman said on Saturday.