SlideShare a Scribd company logo
1 of 19
Сервис POI
Петров Андрей / Hotellook
Определение
POI (point of interest) — достопримечательность
или другой объект, отмеченный точкой на карте.
Задачи
• Показывать расстояние от отеля до
ближайших POI.
• Сортировать выдачу по расстоянию до POI
• Объединить несколько источников данных
• Провести нагрузочное тестирование
Источники данных
• OSM - полигон
• Expedia - перевод
• Популярный сервис -
рейтинг
• Hotellook - отобранные
пляжи и подъемники
Объединение
источников
• Популярный сервис: Sutomorska Plaza
• osm: Sutomore
• expedia: Sutomore Beach
• hotellook: Beach Sutomore
Объединение по
имени
1. Sutomore Beach
2. sutomore beach
3. sutomorebeach
4. sutomore
5. + Левинштейн
Объединение
источников
В результате получается супер
POI, у которой есть:
• Полигон из OSM
• Перевод из Expedia
• Рейтинг из Популярного
сервиса
Пути решения
Посчитать все заранее Посчитать во время
поиска
+ нет проблем с
производительностью
+ поиск нужных отелей среди всех,
например пляжных или лыжных
— фоновый процесс обновление
данных, за которым нужно следить
— скорость обновления данных
— триггеры при обновлении
отелей или пой
+ нет кэша
+ быстрое изменение параметров
— квадратичная сложность
— необходимо укладываться в 5
секунд
Выбор языка
• Python3
$ time python3 calc.py
real0m2.889s
user 0m2.743s
sys 0m0.055s
• GO
$ time ./go_calc
real0m0.274s
user 0m0.250s
sys 0m0.011s vs
Минимальная рамка
Рамка для аэропорта
Рамка для пляжей и подъемников
PostGIS
Было:
Время: 198,762 мс
select * from poi
where ST_DWithin(geom, ST_MakeEnvelope(37.903013,
55.550331, 37.298765, 55.891429, 4326)::geography, 100000);
Seq Scan on poi (cost=0.00..28525.54 rows=423 width=776)
Filter: (((geom)::geography && '0103000020E610000001000007C073'::geography
&& _st_expand((geom)::geography, '100000'::double precision))
AND _st_dwithin((geom)::geography, '0103000020E6100C64B40'::geography,
'100000'::double precision, true))
PostGIS
Стало:
Время: 1,298 мс
select * from poi
where geom && ST_MakeEnvelope(38.803013, 55.390331, 36.298765, 56.891429,
4326) and
category = 'metro_station';
Index Scan using metro_station_gix on poi (cost=0.14..8.16 rows=1 width=776)
Index Cond: (geom && '0103000020E6100000010000000F5DF6B14B40'::geometry)
Подсчет расстояния
$ time ./pythagorus
46291.37379901246
real 0m0.404s
user 0m0.367s
sys 0m0.015s
$ time ./haversine
46291.36062403893
real 0m2.731s
user 0m2.624s
sys 0m0.045s
package main
import "math"
func main() {
for i := 0; i < 10000000; i++ {
distance(37.735882, 55.359127, 37.637795,
55.771724)
}
}
func distance(lon1,lat1,lon2,lat2 float64) float64 {
rad_per_deg := math.Pi / 180
rm := 6371.0 * 1000.0
lon1 = lon1 * rad_per_deg
lon2 = lon2 * rad_per_deg
lat1 = lat1 * rad_per_deg
lat2 = lat2 * rad_per_deg
x := (lon2 - lon1) * math.Cos(0.5*(lat2+lat1))
y := lat2 - lat1
return rm * math.Sqrt(x*x+y*y)
}
Структура сервиса
• Запрос:
[[18.866293,42.282179],
[18.866323,42.284180],
[18.866234,42.283423],
[18.866232,42.282133]]
• Ответ:
{
"pois": [ {
"id": 300640,
"rating": 6.1,
"category": "beach",
"name": "Greco",
"location": {
"lat": 42.283052,
"lon": 18.840151
}
}],
"distance": {
"18.866293,42.282179": {
"300640": 2113,
"303734": 2427,
"304982": 1737,
"309401": 1714
}
}
1. запрос
2. определение рамки
3. расширение рамки
4. поиск пой в БД
5. подсчет расстояния
6. фильтрование
7. сортировка
8. ответ
Нагрузочное
тестирование./vegeta attack -duration 60s -connections 5 -targets piter.json
Latencies [mean, 95, max] 2.06s, 3.67s, 4.93s
1
2
Вопросы
• Контакты
slack: @andrey.petrov
почта: st.andreii@gmail.com

More Related Content

Featured

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellSaba Software
 

Featured (20)

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
 

Создание сервиса по поиску достопримечательностей на карте