our journey to a highly distributed & available search...

30
Instant Search API Build Unique Search Experiences Sylvain Utard VP of Engineering [email protected] @sylvainutard OUR JOURNEY TO A HIGHLY DISTRIBUTED & AVAILABLE SEARCH API… …ON BARE-METAL

Upload: others

Post on 26-Jun-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

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

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

@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

@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

@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

@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

@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

@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

@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

@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

@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

@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

@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

@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

@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

@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

@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

@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

@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

@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

@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

@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

@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

@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

@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

@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

@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

@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

@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

@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

Q & A

Build Unique Search ExperiencesWe are hirin

g in SF and Paris 😊

Sylvain UtardVP of Engineering

[email protected]@sylvainutard