Rust in Production: MeiliSearch
In this interview, I talk with Thomas Payet, the co-founder and COO of MeiliSearch. MeiliSearch is an open-source search engine that is among the top 20 most starred Rust projects on GitHub at the time of writing. We talk about MeiliSearch and how Rust and its ecosystem have helped them create it.
Read further to learn about their experience with Rust and discover tips for starting your own open-source project.
Could you tell us a little about your company and your role there?
MeiliSearch is an open-source search API. Search has always been an issue since computers exist. Today most people are used to super good search results when using Google or Amazon, but it can be challenging to offer such a user experience when you don’t have the means of these Big Tech companies. At MeiliSearch, we are developing an open-source technology that we think can help lots of developers to offer a fantastic search experience out-of-the-box.
I am one of the co-founders (we are three) and COO for Meili, the company behind MeiliSearch. My role consists of synchronizing the teams, ensuring everyone can do their best within our company while following the same goal. Most of us are developers at heart, and because I was perhaps one of the less technical folks, I was one of the first to change my role to support our organization’s growth.
Which parts of the MeiliSearch codebase are written in Rust?
MeiliSearch is a project made of an engine and multiple SDKs and libraries for different languages and frameworks to ease the use of the core engine. The engine is 100% coded in Rust, and we maintain more than 20 integrations in 8 different languages together with the community.
We try not to be advocates for any particular technologies; internally we will just choose the best tool for the job. :)
How did you decide to use Rust for the project? Did any of Rust’s advantages like speed or type/memory safety influence the choice?
Speed and safety are, of course, the main arguments when it comes to Rust.
Two critical things for search engines are performance and relevance. Relevance can be done in any language as long as your algorithm and logic are good. When it comes to performance today, you either go with C++, Rust, or maybe Go.
In our previous jobs, we built a search engine in Go, and we quickly learned about the cons of a garbage collected language when designing a performance-oriented program. When running benchmarks, we identified some slowdowns, and we quickly realized that it was the regular garbage collection that slowed the whole system. ^^
When it comes to C++, it seems more difficult for us to maintain a C++ codebase in the long run. Plus, kero, our CTO, is a Rust developer since the first stable release.
In the end, we never made the “decision” of using Rust since it sounded very obvious to us it was the tool we needed for that job!
Where is Rust great to use, and where does it fall short in your stack?
Rust ecosystem is modern, and it is very easy to use as an everyday language with the actual GitHub contribution flow. We feel very confident building with Rust because it removes a lot of uncertainty we might have with other languages. We can focus on other challenges we face, such as design and performance.
A strong community of CS researchers implements low-level libraries for state-of-the-art optimization that we regularly benefit from. On the other hand, we made multiple iterations to find the proper HTTP framework for the server before ending up using actix-web, which is the most appropriate to our use case.
Any particular Rust libraries that you have found very useful during development and would like to mention?
There are many, but here is our top 3:
- fst from BurntSushi. It allows us to store and search in a dictionary of words, and it is very performant.
- Levenshtein-automaton from fulmicoton. We use it to get words from a dictionary with specific Levenshtein rules very fast.
- roaring-rs, which we use for optimized set operations.
What was the biggest challenge while developing MeiliSearch with Rust?
On the MeiliSearch roadmap, there are some distributed systems features we would like to offer, such as high availability and sharding.
We are pretty jealous of the Go Raft library by Hashicorp. I wish we had something similar in Rust, but so far, we haven’t found such a crate that would help us use a consensus algorithm to build MeiliSearch clusters easily.
We have had it on our minds almost since we began the project two and a half years ago, and we are trying to integrate different Raft implementation libraries, but we have found none that meets our expectations yet. This is one of the biggest challenges that we have in our roadmap.
I saw a repository called milli in the MeiliSearch GitHub profile. Is this the future of MeiliSearch? Would you like to talk about it a little bit?
As we are growing the team and the project, we are continuously learning. We realized last year that to ease the onboarding of external contributors and the development of new features, we needed to re-architect the whole codebase to make it more readable and maintainable.
kero, our CTO, started to work on this new iteration of the engine almost a year ago (August 2020), and we plan to release it in the coming months.
We faced some difficulties internally to prioritize the work on a new iteration of the engine while maintaining the latest stable release of MeiliSearch up-to-date. Still, we can’t wait to release it officially. The performance improvement is incredible!
The milli repo hosts the 4th iteration of the core engine library, but the code that uses this library to make it a usable binary will be released in the MeiliSearch repository.
As I understand, MeiliSearch is fully open source. How do you support it?
We started the project while working as contractors for Louis Vuitton. We developed most of the projects while working with them. At some point, we realized that we had to raise funds from VCs to focus on the open-source project.
We think we can make MeiliSearch sustainable by building a business around it that will sell MeiliSearch as a cloud offering (SaaS) and sell specific features under a business license to companies with specific needs.
Any tips you would suggest for those wanting to launch their own open-source Rust project (can be both technical and non-technical)?
Developing and maintaining an open-source project can quickly become a full-time job for a whole team. I would suggest anyone who wants to get started in maintaining an open-source project to find people to work with because there are many other things to do: you will have to write documentation, contribution guides, answer issues and pull requests!
It’s lovely to work with strangers from the internet you will probably never meet, but I fear it can quickly become overwhelming if you do it alone.
I would like to thank Thomas for his time! If you require a search engine for your app, definitely check out MeiliSearch.
- Could you tell us a little about your company and your role there?
- Which parts of the MeiliSearch codebase are written in Rust?
- How did you decide to use Rust for the project? Did any of Rust’s advantages like speed or type/memory safety influence the choice?
- Where is Rust great to use, and where does it fall short in your stack?
- Any particular Rust libraries that you have found very useful during development and would like to mention?
- What was the biggest challenge while developing MeiliSearch with Rust?
- I saw a repository called milli in the MeiliSearch GitHub profile. Is this the future of MeiliSearch? Would you like to talk about it a little bit?
- As I understand, MeiliSearch is fully open source. How do you support it?
- Any tips you would suggest for those wanting to launch their own open-source Rust project (can be both technical and non-technical)?