launchdarkly/php-server-sdk

LDClient seems to enqueue an event even if the flag is found in APC and/or redis

avidal opened this issue · 1 comments

https://github.com/launchdarkly/php-client/blob/46983adda44dc0be7a39143c476bfa3c68709936/src/LaunchDarkly/LDClient.php#L96

The APC and LDD feature requestors will return null if they don't find the flag. The LDClient, however, looks like it'll enqueue an event to LD regardless of whether or not the flag was found locally. This seemingly means that if you ever call toggle in your application code you are guaranteed to have a fork to curl on every request.

FWIW, the Python client at least seems to do the same thing. Is this a bug?

Hi @avidal,

That's intentional behavior. We create analytics events for every toggle call. In terms of resource use, the PHP client is indeed the least efficient at this since it uses curl. We've just made some changes on our end that should allow us to use pfsockopen in the PHP client instead, which is less resource intensive. FWIW, curl is a commonly used approach to doing this-- many analytics providers end up going this route in PHP.

In Python (and every other SDK), we batch analytics requests and send them asynchronously to minimize resource use.