snappy provides Ruby bindings to Google's Snappy compression library, which prioritizes compression and decompression speed over maximum compression ratios. Snappy achieves moderate compression with extremely fast performance, making it ideal for scenarios where CPU time matters more than storage space or bandwidth. The gem wraps the C++ Snappy library with a simple Ruby interface for compressing and decompressing data.
The library focuses on speed, decompressing data at several hundred MB/s per core and compressing at comparable speeds. While Snappy doesn't achieve compression ratios as high as gzip or bzip2, it operates an order of magnitude faster, making it suitable for real-time compression of high-throughput data streams. The gem provides straightforward compress and decompress methods, handles memory efficiently for large data blocks, and works with both strings and IO streams. Snappy's deterministic compression ensures the same input always produces identical output.
snappy is widely used in big data systems like Hadoop and Cassandra for compressing data blocks, in database systems for reducing storage and I/O, and in network protocols where low-latency compression matters. It's particularly valuable in applications logging high volumes of data, caching systems trading storage for CPU, and scenarios where compression must not become a performance bottleneck. The gem brings Snappy's speed-optimized compression to Ruby applications needing transparent data compression without sacrificing throughput.
gem install snappy Run this gem instantly in your browser without any installation:
Open in RunRuby.dev →