OUR JOURNEY TO A HIGHLY DISTRIBUTED & AVAILABLE SEARCH...
Transcript of OUR JOURNEY TO A HIGHLY DISTRIBUTED & AVAILABLE SEARCH...
![Page 1: OUR JOURNEY TO A HIGHLY DISTRIBUTED & AVAILABLE SEARCH API…perfug.github.io/assets/files/PerfUG29.pdf · • Providing indexing & search offline • Running on the cheapest Android](https://reader034.fdocuments.in/reader034/viewer/2022042400/5f0ee24b7e708231d44168a0/html5/thumbnails/1.jpg)
Instant Search API
Build Unique Search Experiences
Sylvain UtardVP of Engineering
[email protected]@sylvainutard
OUR JOURNEY TO A HIGHLY DISTRIBUTED & AVAILABLE SEARCH API…
…ON BARE-METAL
![Page 2: OUR JOURNEY TO A HIGHLY DISTRIBUTED & AVAILABLE SEARCH API…perfug.github.io/assets/files/PerfUG29.pdf · • Providing indexing & search offline • Running on the cheapest Android](https://reader034.fdocuments.in/reader034/viewer/2022042400/5f0ee24b7e708231d44168a0/html5/thumbnails/2.jpg)
@algolia
A hosted search API
![Page 3: OUR JOURNEY TO A HIGHLY DISTRIBUTED & AVAILABLE SEARCH API…perfug.github.io/assets/files/PerfUG29.pdf · • Providing indexing & search offline • Running on the cheapest Android](https://reader034.fdocuments.in/reader034/viewer/2022042400/5f0ee24b7e708231d44168a0/html5/thumbnails/3.jpg)
@algolia
A hosted search API
![Page 4: OUR JOURNEY TO A HIGHLY DISTRIBUTED & AVAILABLE SEARCH API…perfug.github.io/assets/files/PerfUG29.pdf · • Providing indexing & search offline • Running on the cheapest Android](https://reader034.fdocuments.in/reader034/viewer/2022042400/5f0ee24b7e708231d44168a0/html5/thumbnails/4.jpg)
@algolia
Performance is our DNA
![Page 5: OUR JOURNEY TO A HIGHLY DISTRIBUTED & AVAILABLE SEARCH API…perfug.github.io/assets/files/PerfUG29.pdf · • Providing indexing & search offline • Running on the cheapest Android](https://reader034.fdocuments.in/reader034/viewer/2022042400/5f0ee24b7e708231d44168a0/html5/thumbnails/5.jpg)
@algolia
Replies in milliseconds
From anywhere With intuitive relevance
![Page 6: OUR JOURNEY TO A HIGHLY DISTRIBUTED & AVAILABLE SEARCH API…perfug.github.io/assets/files/PerfUG29.pdf · • Providing indexing & search offline • Running on the cheapest Android](https://reader034.fdocuments.in/reader034/viewer/2022042400/5f0ee24b7e708231d44168a0/html5/thumbnails/6.jpg)
@algolia
Algolia Today
15 regions 36 datacenters
1200+ customers in 100+ countries
40B+ Write operations per month
11B+ User-generated queries per month
![Page 7: OUR JOURNEY TO A HIGHLY DISTRIBUTED & AVAILABLE SEARCH API…perfug.github.io/assets/files/PerfUG29.pdf · • Providing indexing & search offline • Running on the cheapest Android](https://reader034.fdocuments.in/reader034/viewer/2022042400/5f0ee24b7e708231d44168a0/html5/thumbnails/7.jpg)
@algolia
Behind the scene
![Page 8: OUR JOURNEY TO A HIGHLY DISTRIBUTED & AVAILABLE SEARCH API…perfug.github.io/assets/files/PerfUG29.pdf · • Providing indexing & search offline • Running on the cheapest Android](https://reader034.fdocuments.in/reader034/viewer/2022042400/5f0ee24b7e708231d44168a0/html5/thumbnails/8.jpg)
@algolia
Unique set of constraintsHigh volume of Read & Write operations
High-availability
Worldwide data distribution
![Page 9: OUR JOURNEY TO A HIGHLY DISTRIBUTED & AVAILABLE SEARCH API…perfug.github.io/assets/files/PerfUG29.pdf · • Providing indexing & search offline • Running on the cheapest Android](https://reader034.fdocuments.in/reader034/viewer/2022042400/5f0ee24b7e708231d44168a0/html5/thumbnails/9.jpg)
@algolia
Unique set of constraintsHigh volume of Read & Write operations
High-availability
Worldwide data distribution
… obviously with compromises :)
![Page 10: OUR JOURNEY TO A HIGHLY DISTRIBUTED & AVAILABLE SEARCH API…perfug.github.io/assets/files/PerfUG29.pdf · • Providing indexing & search offline • Running on the cheapest Android](https://reader034.fdocuments.in/reader034/viewer/2022042400/5f0ee24b7e708231d44168a0/html5/thumbnails/10.jpg)
@algolia
Software Stack
![Page 11: OUR JOURNEY TO A HIGHLY DISTRIBUTED & AVAILABLE SEARCH API…perfug.github.io/assets/files/PerfUG29.pdf · • Providing indexing & search offline • Running on the cheapest Android](https://reader034.fdocuments.in/reader034/viewer/2022042400/5f0ee24b7e708231d44168a0/html5/thumbnails/11.jpg)
@algolia
• Before being a hosted API
• Small SDK embedded on mobile apps
• Providing indexing & search offline
• Running on the cheapest Android phone
Started as an offline SDK
![Page 12: OUR JOURNEY TO A HIGHLY DISTRIBUTED & AVAILABLE SEARCH API…perfug.github.io/assets/files/PerfUG29.pdf · • Providing indexing & search offline • Running on the cheapest Android](https://reader034.fdocuments.in/reader034/viewer/2022042400/5f0ee24b7e708231d44168a0/html5/thumbnails/12.jpg)
@algolia
• Full C++ search-engine
• Custom data-structures
• Almost no dependencies:
• Google sparsehash (hashtable)
• yajl (JSON parser)
• hiredis (redis client)
Written in C++
![Page 13: OUR JOURNEY TO A HIGHLY DISTRIBUTED & AVAILABLE SEARCH API…perfug.github.io/assets/files/PerfUG29.pdf · • Providing indexing & search offline • Running on the cheapest Android](https://reader034.fdocuments.in/reader034/viewer/2022042400/5f0ee24b7e708231d44168a0/html5/thumbnails/13.jpg)
@algolia
• As close as possible to the HTTP request
• No reverse-proxy
• Built-in hot-reload
• … but far from C10k!!!
Deployed as an nginx module
![Page 14: OUR JOURNEY TO A HIGHLY DISTRIBUTED & AVAILABLE SEARCH API…perfug.github.io/assets/files/PerfUG29.pdf · • Providing indexing & search offline • Running on the cheapest Android](https://reader034.fdocuments.in/reader034/viewer/2022042400/5f0ee24b7e708231d44168a0/html5/thumbnails/14.jpg)
@algolia
Search VS Indexing
• Search
• Read-only
• CPU & RAM
• More priority
• Indexing
• Read & Write
• CPU & RAM & Disk
• Must not impact search performance
2 processes
![Page 15: OUR JOURNEY TO A HIGHLY DISTRIBUTED & AVAILABLE SEARCH API…perfug.github.io/assets/files/PerfUG29.pdf · • Providing indexing & search offline • Running on the cheapest Android](https://reader034.fdocuments.in/reader034/viewer/2022042400/5f0ee24b7e708231d44168a0/html5/thumbnails/15.jpg)
@algolia
• Distributed consensus (RAFT)
• No load balancer
• Smart API clients
• APP_ID.algolia.net
• APP_ID-{1,2,3}.algolia.net
Cluster of 3 machines
![Page 16: OUR JOURNEY TO A HIGHLY DISTRIBUTED & AVAILABLE SEARCH API…perfug.github.io/assets/files/PerfUG29.pdf · • Providing indexing & search offline • Running on the cheapest Android](https://reader034.fdocuments.in/reader034/viewer/2022042400/5f0ee24b7e708231d44168a0/html5/thumbnails/16.jpg)
@algolia
• World-wide replication
• Not a cache
• Geo-IP based routing
• EDNS is a plus
• Users target the closest datacenter hosting their data
• +45 probes around the world calibrating/monitoring it
Distributed Search Network
![Page 17: OUR JOURNEY TO A HIGHLY DISTRIBUTED & AVAILABLE SEARCH API…perfug.github.io/assets/files/PerfUG29.pdf · • Providing indexing & search offline • Running on the cheapest Android](https://reader034.fdocuments.in/reader034/viewer/2022042400/5f0ee24b7e708231d44168a0/html5/thumbnails/17.jpg)
@algolia
• DNS providers are also failing
• 2 DNS providers:
• *.algolia.net
• *.algolianet.com
• TLD tips: .io is a bad idea (slower)
DNS redundancy
![Page 18: OUR JOURNEY TO A HIGHLY DISTRIBUTED & AVAILABLE SEARCH API…perfug.github.io/assets/files/PerfUG29.pdf · • Providing indexing & search offline • Running on the cheapest Android](https://reader034.fdocuments.in/reader034/viewer/2022042400/5f0ee24b7e708231d44168a0/html5/thumbnails/18.jpg)
@algolia
Hardware Stack
![Page 19: OUR JOURNEY TO A HIGHLY DISTRIBUTED & AVAILABLE SEARCH API…perfug.github.io/assets/files/PerfUG29.pdf · • Providing indexing & search offline • Running on the cheapest Android](https://reader034.fdocuments.in/reader034/viewer/2022042400/5f0ee24b7e708231d44168a0/html5/thumbnails/19.jpg)
@algolia
Cloud vs Bare metal
![Page 20: OUR JOURNEY TO A HIGHLY DISTRIBUTED & AVAILABLE SEARCH API…perfug.github.io/assets/files/PerfUG29.pdf · • Providing indexing & search offline • Running on the cheapest Android](https://reader034.fdocuments.in/reader034/viewer/2022042400/5f0ee24b7e708231d44168a0/html5/thumbnails/20.jpg)
@algolia
• Fast CPU
• At least 3.5Ghz
• Only 8 or 12 threads (a single processing unit is single-threaded anyway)
• Best models: Intel E5-1650v2/3
High-end CPU
![Page 21: OUR JOURNEY TO A HIGHLY DISTRIBUTED & AVAILABLE SEARCH API…perfug.github.io/assets/files/PerfUG29.pdf · • Providing indexing & search offline • Running on the cheapest Android](https://reader034.fdocuments.in/reader034/viewer/2022042400/5f0ee24b7e708231d44168a0/html5/thumbnails/21.jpg)
@algolia
• RAM
• 64 or 128GB
• ECC, 1600 or 2400 Mhz
• Indices are in memory
High-end RAM
![Page 22: OUR JOURNEY TO A HIGHLY DISTRIBUTED & AVAILABLE SEARCH API…perfug.github.io/assets/files/PerfUG29.pdf · • Providing indexing & search offline • Running on the cheapest Android](https://reader034.fdocuments.in/reader034/viewer/2022042400/5f0ee24b7e708231d44168a0/html5/thumbnails/22.jpg)
@algolia
• SSD in Raid-0
• 400 GB to 1.5 TB
• Heavyweight I/O operations
• Burned a bunch of them…
• Best models: Intel S3700, S3710
• mmap FTW
High-end SSD
![Page 23: OUR JOURNEY TO A HIGHLY DISTRIBUTED & AVAILABLE SEARCH API…perfug.github.io/assets/files/PerfUG29.pdf · • Providing indexing & search offline • Running on the cheapest Android](https://reader034.fdocuments.in/reader034/viewer/2022042400/5f0ee24b7e708231d44168a0/html5/thumbnails/23.jpg)
@algolia
• Machines spread in 15 regions
• 36 datacenters
• +400 machines
• 11 network providers
• Best practice: 2 or 3-providers setup
Network
![Page 24: OUR JOURNEY TO A HIGHLY DISTRIBUTED & AVAILABLE SEARCH API…perfug.github.io/assets/files/PerfUG29.pdf · • Providing indexing & search offline • Running on the cheapest Android](https://reader034.fdocuments.in/reader034/viewer/2022042400/5f0ee24b7e708231d44168a0/html5/thumbnails/24.jpg)
@algolia
Pricing
![Page 25: OUR JOURNEY TO A HIGHLY DISTRIBUTED & AVAILABLE SEARCH API…perfug.github.io/assets/files/PerfUG29.pdf · • Providing indexing & search offline • Running on the cheapest Android](https://reader034.fdocuments.in/reader034/viewer/2022042400/5f0ee24b7e708231d44168a0/html5/thumbnails/25.jpg)
@algolia
Pricing
![Page 26: OUR JOURNEY TO A HIGHLY DISTRIBUTED & AVAILABLE SEARCH API…perfug.github.io/assets/files/PerfUG29.pdf · • Providing indexing & search offline • Running on the cheapest Android](https://reader034.fdocuments.in/reader034/viewer/2022042400/5f0ee24b7e708231d44168a0/html5/thumbnails/26.jpg)
@algolia
But…
![Page 27: OUR JOURNEY TO A HIGHLY DISTRIBUTED & AVAILABLE SEARCH API…perfug.github.io/assets/files/PerfUG29.pdf · • Providing indexing & search offline • Running on the cheapest Android](https://reader034.fdocuments.in/reader034/viewer/2022042400/5f0ee24b7e708231d44168a0/html5/thumbnails/27.jpg)
@algolia
• Bye bye provisioning APIs…
• … welcome Java & Windows-based applet/KVM
But…
![Page 28: OUR JOURNEY TO A HIGHLY DISTRIBUTED & AVAILABLE SEARCH API…perfug.github.io/assets/files/PerfUG29.pdf · • Providing indexing & search offline • Running on the cheapest Android](https://reader034.fdocuments.in/reader034/viewer/2022042400/5f0ee24b7e708231d44168a0/html5/thumbnails/28.jpg)
@algolia
• Bye bye instant delivery…
• … welcome 2-months shipment
• … and customs taxes /o\
But…
![Page 29: OUR JOURNEY TO A HIGHLY DISTRIBUTED & AVAILABLE SEARCH API…perfug.github.io/assets/files/PerfUG29.pdf · • Providing indexing & search offline • Running on the cheapest Android](https://reader034.fdocuments.in/reader034/viewer/2022042400/5f0ee24b7e708231d44168a0/html5/thumbnails/29.jpg)
@algolia
• Bye bye 2016-ready global providers…
• … welcome local providers
But…
![Page 30: OUR JOURNEY TO A HIGHLY DISTRIBUTED & AVAILABLE SEARCH API…perfug.github.io/assets/files/PerfUG29.pdf · • Providing indexing & search offline • Running on the cheapest Android](https://reader034.fdocuments.in/reader034/viewer/2022042400/5f0ee24b7e708231d44168a0/html5/thumbnails/30.jpg)
Q & A
Build Unique Search ExperiencesWe are hirin
g in SF and Paris 😊
Sylvain UtardVP of Engineering
[email protected]@sylvainutard