我为我的用户建立了电子邮件提醒(现在只有 2,000 个) 因此,每天晚上 crontab 都会执行一个 php 脚本,该脚本查询 mysql 以查找与用户保存的搜索匹配的内容。就我而言,这是一个分类网站,但我想了解一下,以防我必须为更大的客户构建一些东西
我担心的是:
如果我的用户增长 10 倍或 x100 倍?服务器会去吗 碰撞?你有什么建议可以建议吗 管理类似的事情吗?
有什么方法可以保护我的文件 cron/nightly_script.php 为 在调用它之外执行的形式 浏览器的网址?考虑 我在 crontab 中使用字符串 像:
lynx [绝对url/script.php]
电子邮件群发怎么样?对于每个 查询查询是否有结果 脚本发送一封电子邮件,所以这意味着 大量的电子邮件……会是这样吗? 自动视为垃圾邮件并且 那我可以列入黑名单吗?
谢谢!!!
最佳答案
what happen if my user grow x10 or x100 times? is the server going to crash? there any tip you can suggest on manage something like that?
由于大量的内存/CPU 使用,您的服务器可能会崩溃/变得非常慢。您应该使用像 redis/beanstalkd/gearmand 这样的消息队列来限制您的电子邮件警报。我更喜欢 redis。使用blocking pop/push与 predis支持阻止 pop/push 的库。
there is any way to protect my file cron/nightly_script.php to be executed form outside calling it in the url of the browser? consider tham im using a string in crontab like:
如果您想扩展,请不要使用 cron。相反,创建几个守护进程。
- 1 调度发送消息(这部分也可以是cron)到消息队列,
- 1 处理发送到消息队列的消息。
守护进程不需要每次都生成,并且生成过程(相对)昂贵。其次,您的脚本不应再调用任何 URL,而应直接调用 PHP 脚本 (CLI)。
what about the email blast? for each query if the query has results the script sends an email, so it means a blast of emails...is it going to be considered spam automatically and then i could blacklisted?
使用消息队列时,您可以限制自己!
关于php - 关于已保存搜索、程序和安全/性能提示与技巧的电子邮件警报?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3746033/