I have a php library which exposes a few apis which are latency sensitive. There is also a need to capture logs and metrics relevant to these aforementioned apis and send the log and metric data aggregated to a http/https endpoint. Log and metric aggregation and publishing of the same should not impact the api latencies.
Im new to PHP and have found out that there isn't support for asynchronous implementations as there aren't interrupts in the language.
Usage of queueing mechanisms like ActiveMq and the like is also not an option.
PThreads is also not an option as I do not want to make any assumptions on PHP version as my code runs as a library on servers potentially running different PHP versions.
The best I could come up with so far is to have a cron schedule the run of a script that publishes log and metric data but what i dont like about this approach is that it is involved and needs to be done on each machine running the php library.
Any suggestions on how to achieve this in a better way ?
EDIT : Added why Pthreads is not an option.