Feat: Optimize Metrics cache structure to be resource-friendly on bigger usages
Closed this issue · 1 comments
vbartusevicius commented
Is there an existing issue for this?
- I have searched the existing issues
Describe the new feature
Currently, it is unfeasible to enable Feature Metrics for large-scale applications.
Whenever a metric change is triggered, this is what generally happens:
- fetch serialized PHP object from the cache
- deserialize the object
- do some filtering
- generally, increment some counter
- serialize object
- save it to the cache
If we have hundreds of users per second, it gets heavy on the CPU and the network to store metric information if, i.e., Redis is used.
In a real-world application we tried, only the Metric I/O consumes 100Mb/s of network traffic to Redis. This is 10x more than the whole application itself.
To make it more resource-friendly:
- store plain values to avoid serialization
- make use of metric keys to avoid the need for PHP objects
- etc.
Is your feature request related to a problem? (optional)
Unable to use the Metrics feature on more significant projects
Describe alternatives you've considered (optional)
No response
Additional context (optional)
No response
RikudouSage commented
Thanks for the report! I'll be taking a look at what is possible. In the meantime, as a workaround, you can create your own MetricsHandler implementation.