This is what fees are for. Just raise them so the spam transactions aren't viable. People want to write to the blockchain? They need to pay to do it.
@moneroshil