XMPP scalability
When deploying your XMPP capability to the real world, you may need to ensure that your servers will scale. In general, the number of users and JIDs in use at any time has to get pretty high before you need to worry specifically about scalability. Prosody, for example, will handle in the order of hundreds or thousands of users easily. You can find several benchmark test results online and even performance experiments on GitHub that compare the performance of XMPP servers, including Prosody.
As Donald Knuth once said "Remember that premature optimization is the root of all evil". Unless you are experiencing issues due to scalability, you probably do not need to consider the next few paragraphs of advice. Before venturing into the next couple of sections, please be sure that you have cleaned up your server code and you are sure that there is nothing additional that you can squeeze out of the code itself (for example, no duplicated code or functions being called twice, and no...