I’m wondering if there is a way in Meteor or Node to catch Meteor Method calls and throttle how quickly/how much the server tries to actually process?
I have an app where 5000 users (spread between 5 containers) all call the same Meteor Method at the exact same time. I use a lot of caching and bulk inserts and stuff to optimize and all that. And it works good. But presently, when about 1000 of them on single container fire that method, the server’s CPU logically spikes up and some of the method calls have a huge response time. The server goes from a 100ms response time to 5000-10000ms
I’m wondering if there’s some way to simply capture their method call in a queue object/arrary of functions to call, immediately return a response to the client, and then actually process that method call sometime later. Then there could be another function that is actually processing the queue more slowly.
Is this was Node/Meteor is already doing with the event loop under-the-hood anyway? Is this worth investigating?
My server runs all the 1000 calls fairly quickly, but if they were just spaced out by a few seconds the CPU wouldn’t spike and I believe it would run them all much faster and not bottleneck. I’m wondering if just the immediate attempt to try to start processing what that Meteor method does is causing problems.
I suppose though mathematically it could work out that whatever amount those calls are spaced out is probably proportionate in some way to the current delay experienced by the CPU spiking?