PromPHP / prometheus_client_php

Prometheus instrumentation library for PHP applications
https://prometheus.io/docs/concepts/metric_types/
Apache License 2.0
423 stars 93 forks source link

keys/scan redis commands shouldn't be used #90

Closed stefanoparkopedia closed 2 years ago

stefanoparkopedia commented 2 years ago

I've upgraded to Laravel 8 and the performance was poor; digging into it I found out that $registry->getMetricFamilySamples(), when using the Redis adapter, uses the keys Redis command that's a performance killer (redis is single-threaded).

https://github.com/PromPHP/prometheus_client_php/blob/10881142d2c55de19f529ebbcb7f89558c6d46d4/src/Prometheus/Storage/Redis.php#L488

ikhabitoff commented 2 years ago

We also met with a similar problem. Radis recommends using scan instead of keys when looking for keys. I tried to replace the method without breaking the library tests and created pull request. You can try to use my solution temporarily. #91

LKaemmerling commented 2 years ago

Hey,

thanks to @ikhabitoff who fixed it :) The release with the fix was just tagged (2.6.1).