Moodle is large and full featured, like a Winnebago as opposed to a motorcycle. How do you make a Winnebago go 160 MPH? You dont.
You either break it up so the 20,000 users take the quiz at different times, or you run the quiz outside of Moodle and import the grades into Moodle if needed. A simple quiz handling script could serve 1,000 times as many users as Moodle on the same hardware. Small is fast, just like a motorcycle is faster than an RV, so if it needs to be fast, choose something small, and use proper indexes on the database tables.
If you can work on the Moodle PHP code and databases, there is lots of room for improvement. Adding the right indexes on database tables, for example. You can add those where needed (based on measurements) with the XMLDB editor and submit back a patch. Profile your Moodle, with your quizzes, using Xdebug or similar and I'm sure you'll find 80% of the time is spent in a few inefficient functions. Those will probably be loops calling the same query foreach() thousands of times when it could use ONE query to retrieve or update the whole set of records. Patch and submit.
Technically, you COULD strap a huge rocket engine to an RV, and similarly you COULD use ten times as much hardware to serve ten times as many users. Assuming you've already done the things discussed in the performance forum, like a PHP opcode cache, then find the hardware bottleneck. It's probably your disk drives in the database server, but actually check for yourself. If it's the drives in the DB server, put in a 16 wide RAID 10 array of SSD drives and then find the next bottleneck. I've found 3U server with 16 drive bays and RAID cards for under $1,200, so you don't have to spend $25,000 on Netapp to go big on hardware. (Contact me for more info if you want to go this "rocket engine" route with affordable hardware.)