Postgres, Performance and Rails
Andrew Atkinson took a Rails web application that was struggling with load, and optimized it to handle over 9000 HTTP requests per second with an average latency of 35ms end to end. Handling a much higher load, on a smaller RDS instance, with lower latencies. He then shared his expertise by writing a book: "High-Performance Postgres with Rails."
Andrew and I discussed Postgres performance, scalability, design patterns, valuable tools, his career, and some Rails. I tackled Andrew with many of the biggest challenges SaaS developers encounter with Postgres, and Andrew had an answer to everything.
For me, the highlights were his explanation of the N+1 problem, sharding patterns, the use of pgcopydb project to move a noisy neighbor to another DB, and the secret for scaling on a single instance.
Useful links:
- The book: https://pgrailsbook.com
- SaaS Developer Slack - where Andrew answers Postgres questions and will share a discount for his book: http://launchpass.com/all-about-saas
- Andrew's playlist with all his content: https://www.youtube.com/watch?v=W8d3roay29w&list=PL9-zCXZQFyvqhkrefUXAfC4FYntQX9SC9
Tools we mentioned:
- Easier multi-tenancy for Rails: https://github.com/ErwinM/acts_as_tenant
- For read replicas for Rails prior to 6.0: https://github.com/OutOfOrder/multidb
- The fastest way to copy a DB or part of: https://github.com/dimitri/pgcopydb
Chapters:
00:00 Intros
00:48 High-Performance Postgres for Rails
03:54 Meaning of High Performance
05:14 What came first, the Postgres or the rails?
06:46 How does a Rails developer become interested in DB performance?
10:42 Take a loaded DB and make it better
12:36 Dealing with a high rate of updates and deletes
13:20 Architecture and scalability decisions
14:36 Can you get good DB performance with Rails?
17:26 The N+1 problem
21:13 Why work with ActiveRecord?
25:00 Multi-tenant databases
29:57 Tools for horizontal and vertical sharding
33:24 Read-only replicas
39:46 Migrating one tenant to another DB
44:10 Extreme performance
47:27 The key to single instance performance
50:15 It was fast in staging
52:52 Solving DB performance in the app layer
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Postgres, Performance and Rails», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.