Ruby checks runtime

Hey Everybody!
I executed 75 Ruby checks a minute on a windows machine and it took ~5% CPU. Since the checks only include a print command, I think the result is worrying. Has anyone encountered a similar case or has ideas for possible reason?
Thanks

I don’t think you’re alone in this concern about performance on Windows.

Will you please describe which check plugins you are using? We might be able to help you identify plugins that will work better for your Windows systems, e.g. Powershell versions of common system-level checks which are available in the sensu-plugins-windows collection.

With regard to performance, Ruby has two disadvantages in this scenario: dynamic execution and “its not Linux”. Some of this may be out of date information, but historically Ruby on Windows has been ~20% slower than Linux, and that can also vary depending on which compiler was used to build your Ruby.

Various explanations for this discrepancy have been offered, but in the context of Sensu, you’ll have a better experience on Windows if you are able to minimize the number of Ruby plugins in use. Even on Linux, we think folks will be better off with plugins written in compiled languages like Golang.

Despite the performance issues – which exist under Sensu 1.x as well – we continue the effort of repackaging Ruby plugins for use as Sensu Go assets as a convenience. The long term goal is to foster development of more modern plugins. I like ncr-devops-platform/nagiosfoundation plugin collection as an example. Most of the plugins in that collection run on both Windows and Linux, with no dependency on a dynamic runtime like Ruby.

1 Like

What you’re essentially measuring here is ruby VM startup time.

Every time a ruby check is executed, a new ruby VM is loaded and then immediately disposed of. It requires a significant number of disk reads and memory allocations to load and interpret ruby programs.

Loading the VM has a fairly large cost, as you’ve measured for yourself. But you might find the way that cost scales surprising. Starting the ruby VM is likely the most expensive part of running a short-lived ruby program, it won’t take much more CPU to run actual checks, even if they involve network access.

VM startup is a pervasive problem, and people deal with it in a number of ways. We think one of the best ways to deal with it is to choose languages which have very small startup times, which is why we’re bullish on running checks written in Go.

1 Like

Thanks for the answers guys, I really appreciate it!
using Powershell, I did the same tests as I did with Ruby, but performance wise it only got worse, I see you are recommending Golang for that, are there other examples of checks written in Golang except the checks in the nagios link you shared? and performace wise, I understand that since Go is compiled it is probably going to run much much faster, but is it that critical? Is there an option so I can drop to about 1-2% CPU with a not compiled language?
Thanks again!