Scalable, Delayed PHP Processing

后端 未结 15 959
长情又很酷
长情又很酷 2020-12-08 01:41

I\'m working on an online PHP application that has a need for delayed PHP event. Basically I need to be able to execute arbitrary PHP code x many seconds (but it could be da

15条回答
  •  醉话见心
    2020-12-08 02:04

    I am not sure why you are trying to avoid cron. You could create a queue of requests in a table, and have cron fire up a process to check for current jobs.

    There are a few issues, depending on your exact requirements. For instance:

    • How precise must the call be?
    • How long would each call take?
    • What is the normal and peak load in any given period?

    So if you want precise execution, or execution takes longer than a second, or there is the potential for a heavy load, then the cron approach can run into problems.

    I have many daeons that run PHP (using daemontools). With this approach you could hold the requests in core and perform whatever timing you wanted internally.

    However if exact and relaible timing is what you want you should probably move away from PHP altogether.

提交回复
热议问题