How is the CDN Pro CPU Usage calculated?
CDN Pro的CPU使用如何计算？
CDN Pro collects CPU usage based on NGINX’s “event-driven, non-blocking” architecture. Every request to CDN Pro is put to sleep when waiting for I/O activities, awakened when some data is ready to be processed, and then put to sleep again when the processing is completed. This can occur many times during the lifecycle of a request. CDN Pro uses the function clock_gettime() on Linux to obtain the amount of CPU time, in nanoseconds, spent on each active interval of each request and accumulated along the way. At the end of the request’s lifecycle, we collect the total consumed CPU time for the request, just like how we treat the bytes transferred.
CDN Pro基于NGINX的“事件驱动、非阻塞”架构收集CPU使用情况。在等待I/O活动时，对CDN Pro的每个请求都会进入睡眠状态，在某些数据准备好进行处理时会被唤醒，然后在处理完成后再次进入睡眠状态。在请求的生命周期中，这可能会发生多次。CDN Pro在Linux上使用函数clock_gettime（）来获取每个请求的每个活动间隔所花费的CPU时间量，以纳秒为单位，并在此过程中累积。在请求生命周期结束时，我们收集请求的总CPU消耗时间，就像我们处理传输的字节一样。