[(Genesis 19:24:) AND THE LORD RAINED DOWN.] This is what Scripture says (Psalms 11:6): "He will rain down upon the wicked snares, fire and brimstone and a scorching wind, the portion of their cup." This portion was already prepared before the world was created, as it is said: "the portion of their cup." What is the meaning of "the portion of their cup"? (Psalms 75:9:) "For a cup is in the hand of the LORD, and the wine foams; it is full of mixture, and He pours out from this, etc." "For a cup is in the hand of the LORD, etc." Lest you say that it is lacking, the verse teaches, "full of mixture." Lest you say that they did not drink from it, the verse teaches, "and He pours out from this." "Indeed, all the wicked of the earth shall drain its dregs and drink them" (ibid.). Therefore it is said, "the portion of their cup": from that very cup they drank, as it is said, "the portion of their cup."
The Cup of Wrath Prepared for Sodom Before Creation
Midrash Tanchuma Buber, Vayera 18:1
[וה' המטיר]. זש"ה ימטר על רשעים פחים אש וגפרית ורוח זלעפות מנת כוסם (תהלים יא ו), המנה הזאת היתה מתוקנת עד שלא נברא העולם, שנאמר מנת כוסם, מהו מנת כוסם, כי כוס ביד ה' ויין חמר מלא מסך ויגר מזה וגו' (שם עה ט), כי כוס ביד ה' וגו', שמא תאמר שהוא חסר, תלמוד לומר מלא מסך, שמא תאמר לא ממנו היו שותים, תלמוד לומר ויגר מזה, אף שמריה ימצו ישתו כל רשעי ארץ (שם), לכך נאמר מנת כוסם, מאותו הכוס שתו, שנאמר מנת כוסם.