We were building our performance setup and we noticed, initially that the numbers were slightly better in Meteor 3 vs Meteor 2.
For methods, it showed ~28% speed increase, ~10% lower CPU usage, and ~16% less RAM consumption on standard server execution, likely due to the Node upgrade itself.
However, in reactive flows, we noticed that after 4 concurrent connections (in our extreme testing scenario, it can only be relative to our testing setup the Meteor 3 app started to not respond at all, while Meteor 2 would still work fine. We also received some reports from companies facing the same problem when deploying to production, especially when using Publish Composite.
Clarification on our testing scenario: 4 concurrent connections, per second, over a minute, and doing a process that triggers reactivity incrementally on connected users. This is a very extreme scenario and it won’t affect most of the applications.
After writing a custom async resource profiling logic I noticed that we are producing many thousands of async resources, and the first thing that came to mind was the context from ALS/bindEnvironment, since it needs to be allocated and then deallocated, so should apply big pressure on GC and even on the event loop. But it was mainly conjecture, now I believe it is still something we can optimize, but not the main problem.
Now the good news:
Yesterday after implementing a custom logic with an event loop monitor I could trim down and focus on the resources created only when the event loop is lagging, turned out to point to a big portion of the observer/multiplexer logic and also zlib
which is used by permessage-deflate
for sockjs message compression. Disabling compression seems to fix the issue we noticed and significantly reduce CPU/memory.
As permessage-deflate
is old, possibly it didn’t age well as Node.js evolved. We will be releasing a beta completely disabling it, and then research if we need to add it back. I believe the benefits outweigh any potential cost with bandwidth and we can find a better approach in the future.
We will publish the numbers in a few days as we finish validating the changes, but at first Meteor 3 might be way faster than Meteor 2, after all. And that’s without optimizing the observer/multiplexer logic, and there is a lot of room for improvement there, I believe.
About the packages that will be brought to the core, to my knowledge, are: Roles, Apple Oauth, Migrations, and possibly Collection 2 or some features within it. If you have suggestions let us know.