Peter Allott, 37, who used to work at St Benedict's Catholic School in Ealing, pleaded guilty to three counts of making indecent images, one count of distributing indecent images and one count of possessing extreme pornography.
Blackfriars Crown Court heard that Mr Allott possessed more than 200 images of children, some as young as two years old.
It saw some of the images which showed children in "pain and distress".
The former deputy head also pleaded guilty to possession of the illegal party drug MDMA.
Mr Allott was abused as a child and was spending up to 600 pounds a week on drugs.
Judge Hillen said in summary: "You were leading a double life.
"Over the weekends your were engaged with chemsex parties using crystal meth and MCAT, having sex with multiple partners but also watching these images.
"On Monday morning you were putting on your suit and you would be the brilliant high-flying deputy head master doing your public duty.
"Children suffered for your sexual gratification.
"That is a knowledge that you must bear with you for the rest of your life."