gpt4 book ai didi

php - 将 Ubuntu 时钟源从 xen 切换到 tsc 会影响 php/Laravel 应用程序吗?

转载 作者:行者123 更新时间:2023-12-04 18:44:53 27 4
gpt4 key购买 nike

背景

我们开始在我们的 laravel 应用服务器(托管在 ubuntu ec2)上使用新的 relic,但随后立即注意到我们的 aws cloudwatch 中的延迟增加了:
enter image description here

New relic 技术支持立即建议我们将时钟源从 xen 切换到 tsc:

It appears that the clocksource on your system isn't supporting vDSO. Since the PHP Agent heavily relies on the gettimeofday() system call to determine the length of time of segments and transactions, clocksource plays a big role in preventing system calls from hitting the system itself which greatly speeds things up.

In this particular scenario we recommend using the tsc clocksource. We have seen big performance gains with tsc clocksource enabled and I wanted to ask if it would be possible for you to temporarily enable the tsc clocksource to see if the overhead reduces.

If New Relic is the only application for which accurate timing is required, or if you're only concerned with accurately measuring shorter durations, tsc is a good choice for clocksource.



我做了一个快速 search关于两个时钟源之间的差异,并没有发现任何巨大的危险信号(这里提到了这些问题:
然而,TSC 也有其自身的问题,包括:

  • Its frequency is unknown, and it needs to be measured with PIT, CMOS, or ACPI timer.
  • The register is writable and the reading can differ on different CPUs.
  • TSC can stop in some low-power C states of the processor. This doesn't usually happen on modern hardware.
  • TSC getting out-of-sync on some big NUMA systems was observed in the past. Luckily, the number of such systems was limited.
  • SMI handlers may reset the counter.


所有这些对我来说听起来都很陌生,但似乎它们只与微时间保持需求相关(例如分析器等),我认为它与我们可以容忍不准确的 php/laravel 应用程序并不真正相关时间阈值最多为 3 秒(但不会更多,因为我们的应用程序依赖于向用户发送的实时通知)。

我的假设是否正确?

附录 I:new relic 支持团队关于如何从 xen 切换到 tsc 的说明:

To set the current clock source to a different value

Run bash as a super user to override the current_clocksource:

sudo bash -c 'echo tsc > /sys/devices/system/clocksource/clocksource0/current_clocksource' Run the dmesg command to view the kernel messages:

dmesg | less If the override was successful, the following message appears:

clocksource: Switched to clocksource tsc

最佳答案

这周我对这个话题做了很多研究。我的堆栈与您的堆栈非常相似,唯一的区别是我在 ECS Optimized AMI 上运行。

如果您的应用程序不需要英里秒精度,那么切换到 TSC 应该没问题。确保您正在使用更新的内核在新一代上运行。这是我看到的影响,基本上有一半的实例:https://imgur.com/TllxFXs

AWS 建议使用自己的服务来保持时间同步:https://aws.amazon.com/blogs/aws/keeping-time-with-amazon-time-sync-service/

我仍在整理我的引用资料,如果您需要更多信息,请告诉我。

关于php - 将 Ubuntu 时钟源从 xen 切换到 tsc 会影响 php/Laravel 应用程序吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51935151/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com