简体   繁体   English

将日志从 PHP 传送到 AWS ElasticSearch/OpenSearch 时的性能

[英]Performance when shipping logs from PHP to AWS ElasticSearch/OpenSearch

Is it recommended to ship logs directly from a PHP app to ElasticSearch?是否建议将日志直接从 PHP 应用程序发送到 ElasticSearch? Or is it always better to store to file and use filebeat to ship the logs?还是存储到文件并使用 filebeat 发送日志总是更好? I'm familiar with C# and Serilog implementation sending directly to ES and we've never had an issue with it, but was wondering if the same could be done with a PHP app using Monolog without performance being severely impacted.我熟悉直接发送到 ES 的 C# 和 Serilog 实现,我们从来没有遇到过问题,但想知道是否可以在不严重影响性能的情况下使用 Monolog 的 PHP 应用程序完成同样的操作。 I'm assuming Serilog is able to asynchronously send the logs, I'm not sure if the Monolog implementation on PHP is able to do that or if it would only be OK to ship directly as long as they're infrequent error logs but info/debug logging would cripple performance.我假设 Serilog 能够异步发送日志,我不确定 PHP 上的 Monolog 实现是否能够做到这一点,或者是否只能直接发送,只要它们很少出现错误日志但信息/debug 日志记录会削弱性能。 Anybody have any experience doing this?有没有人有这样做的经验? For additional background, we'd be using AWS OpenSearch and the PHP app would also be running at AWS in ECS/Fargate containers, so it would be inside the same network.对于额外的背景信息,我们将使用 AWS OpenSearch,并且 PHP 应用程序也将在 AWS 的 ECS/Fargate 容器中运行,因此它将位于同一网络内。

personally I would recommend logging to a file and then shipping, no matter the end datastore you end up chosing我个人建议登录到文件然后发送,无论您最终选择哪个最终数据存储

the reason is that otherwise you need to handle a tonne of logic in your client - load balancing/failover, retries, error handling, back pressure - and while another client library for that datastore may abstract some of this out, it's probably not the best place for it原因是,否则您需要在客户端中处理大量逻辑——负载平衡/故障转移、重试、错误处理、背压——虽然该数据存储的另一个客户端库可能会抽象出其中的一些,但它可能不是最好的它的地方

the biggest issue there would be back pressure.最大的问题是背压。 what happens if something happens that delays, or stops, logging to your datastore?如果发生延迟或停止记录到您的数据存储的事情会发生什么? do you keep the log in memory and retry later?您是否将日志保存在内存中并稍后重试? do you block till the log is stored?你会阻塞直到日志被存储吗? how do you manage those aspects你如何管理这些方面

if you log to a file (or even stdout for containers) you have a pretty clear delineation point for your code.如果您登录到文件(甚至是容器的标准输出),您的代码就会有一个非常清晰的描述点。 you will likely have a backup of the log incase you ever need to check it, and you can use task specific tooling to ship your logs您可能会备份日志以防您需要检查它,并且您可以使用特定于任务的工具来发送您的日志

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM