Giter Site home page Giter Site logo

SySV Errors after a while. about php-daemon HOT 2 CLOSED

lifo101 avatar lifo101 commented on June 25, 2024
SySV Errors after a while.

from php-daemon.

Comments (2)

phuze avatar phuze commented on June 25, 2024

I stayed away from workers due to limitations with the IPC layer. A few things the author has noted:

If you spend too much time polling in each iteration the rest of your daemon will suffer. So, try not spend more than 1 second at a time in the execute loop.

One thing to be aware of. The daemon is not really meant for high-speed processing. The 'calling' mechanism in the back-end that communicates with sub-processes can sometimes break if you make too many calls too quickly. A few messages per second is fine, but hundreds per second will start to become unstable, most likely. I've never tested how much I could do within workers.

Looking at your logs, I think you're encountering those limitations:

DEBUG: Daemon::wait: Loop took too long.

I'm not sure if it'll help your situation, but have you considered using tasks instead of workers? Tasks are the same thing, only they don't communicate back to the main daemon process thereby avoiding the IPC bottleneck entirely. They are fire and forget.

In my use case, I've got 5 daemons running, each one monitors various azure queues and fires off various processes (tasks) when there are messages in a queue. Each task runs as its own process in linux -- they exit gracefully and I have been hammering these daemons pretty hard. I can process hundreds of messages per second using this approach and its been super stable.

Just gotta make sure you keep the execute() logic light and have your tasks do all the heavy lifting. I process multiple message per task before letting that task exit -- just so im not spawning a process for every single message a queue.

Example:

/**
* Main application logic.
* Called every loop cycle
**/
protected function execute()
{

    # broadcast a heartbeat every 5 minutes (based on run interval)
    if ($this->getLoopIterations() % 60 == 0) {
        $this->log("service status: okay");
    }

    try {
        # get order queue counts
        $createCount = AzureQ::queueCount('shopify-create');
        $ordersCount = AzureQ::queueCount('shopify-orders');
    } catch (Exception $e) {
        return;
    }

    # kick off appropriate processor
    if ($createCount > 0) { $this->task('OrderCreate'); }
    if ($ordersCount > 0) { $this->task('OrderProcess'); }

}
use Lifo\Daemon\Task\AbstractTask;

class OrderProcess extends AbstractTask
{

# easy access to the daemon logging routines
# so we don't have to use Daemon::getInstance()->log
use \Lifo\Daemon\LogTrait;

public function run()
{
    #do stuff
}

from php-daemon.

lifo101 avatar lifo101 commented on June 25, 2024

nothing i can do with this right now.

from php-daemon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.