treasure-data / serverengine

A framework to implement robust multiprocess servers like Unicorn
Apache License 2.0
759 stars 86 forks source link

100% CPU usage on Windows #76

Closed acty-yoshida closed 7 years ago

acty-yoshida commented 8 years ago

I found this problem using fluentd in Windows Server 2012R2. The debugging results, I think following point is the cause of problem.

class MultiWorkerServer < Server
    def run
      while true ### loop very high frequency
        num_alive = keepalive_workers
        break if num_alive == 0
        wait_tick  ### no wait at windows os
      end
    end
end
tagomoris commented 8 years ago

Hmm, this if should be out of unless ServerEngine.windows?: https://github.com/treasure-data/serverengine/blob/master/lib/serverengine/process_manager.rb#L247

acty-yoshida commented 8 years ago

I think so. I've tried it in my environment. That's works fine.

def tick(blocking_timeout=0)
  if @closed
    raise AlreadyClosedError.new
  end

  # move 
  if @rpipes.empty?
    sleep blocking_timeout if blocking_timeout > 0
    return nil
  end

  time ||= Time.now

  unless ServerEngine.windows?
    # heartbeat is not supported on Windows platform.

    ...
tagomoris commented 8 years ago

@acty-yoshida thank you to try it! I pushed #77.