在 LAMP 上运行重复维护流程
我正在开发一个拍卖网站,需要在后台运行维护脚本以确保平稳运行。诸如结束拍卖、开始拍卖等等……
当我研究这个主题时,似乎有很多选择,但没有明确的答案。
做这种事有没有标准?到目前为止我的研究已经发现了这些可能性:
PHP 和 CRON,太慢了,没有证据表明其他人使用这种方法?
MYSQL存储过程:不想处理MYSQL语言的
BASH脚本???
C脚本???
我希望有经验的人可以告诉我我所缺少的优点和缺点,在决定使用哪种方法时需要考虑的其他事情等等......
速度(和效率)非常重要。
谢谢!
I am developing an auction site that requires maintenance scripts to be run in the background to ensure smooth running. Things such as ending auctions, starting auctions, etc...
There seem to be many options and no definite answers when I research the subject.
Is there a standard for doing this sort of thing? My research so far has uncovered these possibilities:
PHP and CRON, too slow, no evidence of anyone else using this method?
MYSQL stored procedures: don't want to deal with MYSQL language
BASH script???
C script???
I hope that someone with experience can inform me of pros and cons that I am missing, other things to think about when deciding which method to use, etc...
Speed (and efficiency) are very important.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我有一个网站,使用 PHP + Cron 进行一些相当密集的维护。我建议您这样做,因为您可以重用主应用程序中的库。 php在什么情况下太慢了?
除非您在应用程序中进行一些认真的数字运算,否则大部分负担都在数据库上。在这种情况下,只有 Bash/cscript 的性能会比 php 差。
I have a site that does some pretty intensive maintenance using PHP + Cron. I would recommend that since you can reuse libraries from the main application. In what way is php too slow?
Unless you doing som serious number crunching in the application, most of the burden is on the database. In that case only Bash/cscript would have worse performance than php.
这可能更像是一个 http://serverfault.com 问题。
如果您需要自定义的东西,因为上面的方法不适合您,请选择使用您已有的库和编写的技术的东西,即 perl、python、C、php 等(这样您就不必移植如果您需要稍后扩展它以在做出计时决策之前访问某些内容),并编写一个为您完成此操作的自定义程序。然后让 cron 确保它始终处于运行状态,并且它可以自己而不是在 cron 中完成更耗时的事情。
This might be more of a http://serverfault.com question.
If you need something custom because the above won't work for you, pick something that uses the technologies you already have libraries and things written in, i.e. perl, python, C, php, whatever (so that you don't have to port work you've already had to do, if you need to expand it later to access things before making timing decisions), and write a custom program that does it for you. Then have cron make sure that it's always up, and it can do the more time-intensive things itself rather than in cron.
我开发并管理了一个拥有 700 多个数据库的庞大数据库系统 [别问...],在更新、摘要、结构同步等方面需要大量维护。
所有这些都是通过 Bash 和 PHP 完成的通过 cron 定期运行的脚本。有些每 10 分钟一次,有些每小时一次,有些每天一次,有些每月一次 - 我从来没有遇到过任何速度/性能问题,只要您对脚本和 SQL 语句进行编码,以便它们在运行时高效!
最重要的事情之一是调整 MySQL 索引,以确保定期计划的作业快速运行,从而最大限度地减少 cron 运行时发生的常规 CPU 命中。
I have developed and manage a massive database system with 700+ databases [don't ask...], which need plenty of maintenance in terms of updates, summaries, synchronisation of structures, etc.
All of this is done through Bash and PHP scripts running regularly through cron. Some every 10 minutes, some hourly, some daily, some monthly - never have I had any issues with speed / performance, so long as you code the scripts and SQL statements so that they are efficient when run!
One of the most important things is to tune your MySQL indexes to ensure that your regular scheduled jobs run quickly, minimising the regular CPU hits that occur when the cron's run.