basecamp / easymon

Easy Monitoring
MIT License
205 stars 16 forks source link

Speed up DB checks #21

Closed jeremy closed 7 years ago

jeremy commented 7 years ago

User their optimized connection.active? instead of a full SELECT query, skipping extra client & server overhead on AR adapters that offer a faster path.

The mysql2 adapter, for example, uses a connection PING command to check connection liveness. I measured ~0.39ms to SELECT and ~0.07ms to PING on a typical production host.

jeremy commented 7 years ago

Tests ❤️ Thank you @anoldguy!

matthewd commented 7 years ago

For the record, active? shouldn't ever raise. But it makes sense for us to still handle it just in case, so ¯\_(ツ)_\/¯

jeremy commented 7 years ago

Suppose the klass.connection case could raise, though.