teamtnt / tntsearch

A fully featured full text search engine written in PHP
https://tnt.studio/solving-the-search-problem-with-laravel-and-tntsearch
MIT License
3.08k stars 292 forks source link

Indexer killing at Shared hosting. May we add sleep after X sec? #103

Closed lgXenos closed 7 years ago

lgXenos commented 7 years ago

Hi If I understand correctly - your Search are solution for budget hostings. Or light variant as for Sphinx Right?

I'm get message in my hosting console now: Killed... Wow... Why? Permanently high load in my script :) But if highload were short - hoster promise not killing my script

So... File: teamtnt/tntsearch/src/Indexer/TNTIndexer.php Line: 251

while ($row = $result->fetch(PDO::FETCH_ASSOC)) { $counter++;

If I'm add some code, you are approve it? Or I'm better do this in my repo?

For example:

 class TNTIndexer {
    public $maxSecDurationPerCycle = 999; // I'm using 2 sec
    public $sleepMsecAfterCycle =  0.01 * 1000000; // I'm using 5 sec
    //
    // scroll-down...
    //
    $restartTime = time();
    while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
    if((time() - $restartTime) > $this->maxSecDurationPerCycle ){
        usleep($this->sleepMsecAfterCycle);
        $restartTime = time();
    }
    //
    // scroll-down...
    //
}
nticaric commented 7 years ago

I guess changing your hosting provider would be a better solution here. Digital Ocean has low cost plans starting from $10 per month