Sonic, the lightweight search engine backend is an alternative to Elasticsearch
Looking for a lightweight alternative search backend to Elasticsearch? Sonic is a search backend written in Rust. It aims for a low CPU footprint and uses around 30 MB of RAM. See its speed benchmarks and its search query features. Find out how to get started.
According to the DB-Engines Ranking, Elasticsearch is currently in the top ten database management systems. Despite its popularity and usage, alternative tools exist for users who feel that Elasticsearch does not meet their specific use cases. Sonic is one of these alternatives. It is a “fast, lightweight & schema-less search backend”, runs on just a few MBs of RAM, and was written in Rust.
We recently highlighted it on our March 2019 GitHub list, where we highlight some of the GitHub repos that trended that month. Today we are giving more time for it to shine in the spotlight.
Lightweight Elasticsearch alternative
From creator Valerian Sailou’s blog, Sonic’s design philosophy comes from answering four questions:
Is this feature really needed?
How can we make it simple?
Is Sonic still fast and lightweight with it?
Is configuring Sonic getting harder with that new shiny thing?
Passing this test allows for Sonic to remain lightweight and capable of running on low resources.
- Search term bucket organization.
- Automatic spell-check and typo correction for queries.
- Real-time word auto-complete suggestions allow for creating responsive search engines.
- Multi-lingual text language support in the lexing system and Unicode support.
- Sonic Channel protocol helps search your index and perform administrative actions. Use libraries to connect to Sonic Channel from your apps over LAN. Read more about Sonic channel and how it can manage your search index.
- Coded in Rust. Rustlang provides high performance and stability.
Testing Sonic out
See the benchmarks on GitHub. Explore several scenarios to see how quickly Sonic performs. According to GitHub, its creator built Sonic to counteract the expenses of using ELS and other database tools that were too heavyweight to scale. Creating this search backend helped save money and disk space.
You can test out its speedy performance in real time. Crisp integrates Sonic for its search results and can be viewed on the help desk page. Try typing in more than two characters in the search bar and see the results populate. Both search and suggestion results use Sonic.
Download Sonic from the release page. The latest release v1.1.9 from March 29, 2019 fixes a dead-lock, reworks a command internal, and adds two more fixes.
You will need Docker and NodeJS in your test environment before starting.
Before using, familiarize yourself with its limitations to know if it fits your specific use cases. Sonic Natural Language Processing system is unable to perform at the sentence-level and only works on at the word-level. Read up on this and other limitations, including its hardware limits, on GitHub.
According to the interview, Valerian is ultimately planning to write extensive Markdown documentation about the inner workings behind Sonic. He plans to detail each step of a query. Track his progress on this GitHub issue.
Result-wise, it performs up to expectations. From the interview:
Our Sonic instance indexes half a billion objects (messages, articles, contacts). The compressed index is 20GB, and CPU usage under load is 10% of 1 Intel Xeon core. Sonic uses ~200MB of RAM for such a large index at worst, and 20MB when it’s cold-started. Search latency is under 1ms.