睡眠功能使用服务器资源? [英] Sleep function uses server resources?

查看:119
本文介绍了睡眠功能使用服务器资源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个使用睡眠功能的理由:第一,在与我们联系20分钟后自动发送确认电子邮件给客户。我不想使用cron作业,因为我希望它完全是20分钟(并且我厌倦了我的web服务器向我发送电子邮件,告诉我他们发起了cron作业......每20分钟发送一封新邮件! )第二个原因:我听说有人使用睡眠功能发送群发电子邮件。由于我的服务器每小时只允许发送100封电子邮件,因此我希望使用睡眠功能让脚本睡眠一个小时,然后继续收到。



我的问题是这样的吗?它使用服务器资源吗?它会减慢速度吗?使用睡眠功能还有其他问题吗?提前致谢!

解决方案

虽然进程是 sleep 不占用CPU时间,但进程的工作集仍然需要物理内存和/或页面文件来支持该进程。换句话说,PHP解释器进程需要继续运行。只要你的服务器有足够的RAM,这应该不成问题。


I've got two reasons to use a sleep function: first, to automatically send a confirmation email to a client 20 minutes after they contact us. I don't want to use cron jobs because I want it to be exactly 20 minutes (and I'm sick of my web server sending me emails telling me they initiated a cron job.....a new email every 20 minutes!)

Second reason: I've heard of people sending out mass emails using the sleep function. Since my server will only allow 100 emails an hour, I want to use the sleep function to have the script sleep for an hour then continue where it picked up.

My question is this: does it use server resources? Will it slow things down? Are there any other problems with using the sleep function? Thanks in advance!

解决方案

While a process is sleeping it will not consume CPU time, but the process' working set still requires physical memory and/or pagefile to support that process. In other words, the PHP interpreter process needs to keep running. So long as your server has enough RAM this shouldn't be a problem though.

这篇关于睡眠功能使用服务器资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆