SlideShare una empresa de Scribd logo
1 de 31
Descargar para leer sin conexión
How to debug.

Everything.
Vsevolod Solovyov
Prophy.Science
Секретный
фокус
Код не работает, 

буду что-то менять, 

пока не заработает
Библиотека не
собирается, 

буду что-то менять,
пока не соберется
Научный метод
Алярм!

Сайт лежит!
Сайт лежит
•Половина страниц открывается быстро

•Половина никогда

•Потом всё ложится
Гипотеза!
Эксперимент
•Половина страниц открывается быстро

•Половина никогда

•Потом всё ложится

•Рестарт uwsgi помогает наполовину
Наблюдаем
•Половина страниц открывается быстро

•Половина никогда

•Потом всё ложится

•Рестарт uwsgi помогает наполовину

•htop, iotop — везде в норме
Достанем
инструменты!
Блокирующие запросы в БД
•SELECT !!... locking queries;
•Все ждут ALTER TABLE

•Запрос ALTER TABLE ждёт кого-то

•Кто-то — незакрытая транзакция
Больше наблюдений
•Мониторинг

•Логи

•htop, iotop — загрузка процессора, диска

•EXPLAIN — план выполнения запроса в БД

•py-spy — профилирование Python

•Всякое специфичное
py-spy flamegraph
Знать базовые вещи
•Структуры данных

•Особенности языка

•Как устроены ОС

•Как устроена ваша БД

•Как работает сеть

•Виртуальные машины

•Контейнеры

•Сборщики мусора

•...

•https://jvns.ca/zines/
Stranger Things
Stranger Things
•Приложение перестало стартовать

•Написано на Clojure, запускаем внутри Docker

•Обновили кучу зависимостей

•Качает зависимости на старте и молчит

•В начале нашего кода print не выполняется
jstack pid
at java.io.FileInputStream.readBytes(Native Method)
at java.io.FileInputStream.read(FileInputStream.java:255)
at sun.security.provider.SeedGenerator$URLSeedGenerator.getSeedBytes(SeedGenerator.java:539)
at sun.security.provider.SeedGenerator.generateSeed(SeedGenerator.java:144)
at sun.security.provider.SecureRandom$SeederHolder.<clinit>(SecureRandom.java:203)
at sun.security.provider.SecureRandom.engineNextBytes(SecureRandom.java:221)
- locked <0x00000000e3a2f5f0> (a sun.security.provider.SecureRandom)
at java.security.SecureRandom.nextBytes(SecureRandom.java:468)
at java.math.BigInteger.randomBits(BigInteger.java:634)
at java.math.BigInteger.<init>(BigInteger.java:623)
at org.bouncycastle.crypto.generators.ECKeyPairGenerator.generateKeyPair(Unknown Source)
at org.bouncycastle.jcajce.provider.asymmetric.ec.KeyPairGeneratorSpi$EC.generateKeyPair(Unknown Source)
at buddy.core.keys.jwk.ec$get_curve.invokeStatic(ec.clj:87)
SecureRandom
•Не псевдослучайная последовательность

•So secure

•Much seed

•Нужно больше энтропии

•> cat /proc/sys/kernel/random/entropy_avail

45
Кто сказал
"Python"?
Подстилаем соломку
•Учимся читать (чужой) код

•Пишем простой код
Простой код
•Нет множественному наследованию

•Нет наследованию

•Нет классам (кроме датаклассов)

•Нет мета-программированию

•Нет изменению аргументов функции
Математический код
•В статье написано 5 формул

•В коде написано 400 строк

•Баги портят результат

•Баги незаметно портят результат
Математический код
•Экстремально точные названия переменных

•Листик с личным пересказом всех формул

•Code review с повтором процесса
Напоследок
•Новые технологии требуют новых инструментов

•Общие подходы всегда одинаковые

•Все врут

•Главное - не бояться!
Спасибо за
внимание
Вопросы?
Vsevolod Solovyov
CTO at Prophy Science
@murkt

vsevolod.solovyov@gmail.com

Más contenido relacionado

La actualidad más candente

Andrew Aksyonoff "Архитектура вокруг поиска"
Andrew Aksyonoff "Архитектура вокруг поиска"Andrew Aksyonoff "Архитектура вокруг поиска"
Andrew Aksyonoff "Архитектура вокруг поиска"Fwdays
 
Отладка производительности приложения на Erlang / Максим Лапшин (Erlyvideo)
 Отладка производительности приложения на Erlang / Максим Лапшин (Erlyvideo) Отладка производительности приложения на Erlang / Максим Лапшин (Erlyvideo)
Отладка производительности приложения на Erlang / Максим Лапшин (Erlyvideo)Ontico
 
Бинарные (файловые) хранилища- страшная сказка с мрачным концом
Бинарные (файловые) хранилища- страшная сказка с мрачным концомБинарные (файловые) хранилища- страшная сказка с мрачным концом
Бинарные (файловые) хранилища- страшная сказка с мрачным концомDaniel Podolsky
 
А. Аксенов "Как мы разрабатываем Сфинкс", DUMP-2014
А. Аксенов "Как мы разрабатываем Сфинкс", DUMP-2014А. Аксенов "Как мы разрабатываем Сфинкс", DUMP-2014
А. Аксенов "Как мы разрабатываем Сфинкс", DUMP-2014it-people
 
Евгения Фирсова "Выкладка вёрстки — просто, быстро, безопасно"
Евгения Фирсова "Выкладка вёрстки — просто, быстро, безопасно"Евгения Фирсова "Выкладка вёрстки — просто, быстро, безопасно"
Евгения Фирсова "Выкладка вёрстки — просто, быстро, безопасно"Yandex
 
My talk at YouCon Saratov 2016
My talk at YouCon Saratov 2016My talk at YouCon Saratov 2016
My talk at YouCon Saratov 2016Alex Chistyakov
 

La actualidad más candente (6)

Andrew Aksyonoff "Архитектура вокруг поиска"
Andrew Aksyonoff "Архитектура вокруг поиска"Andrew Aksyonoff "Архитектура вокруг поиска"
Andrew Aksyonoff "Архитектура вокруг поиска"
 
Отладка производительности приложения на Erlang / Максим Лапшин (Erlyvideo)
 Отладка производительности приложения на Erlang / Максим Лапшин (Erlyvideo) Отладка производительности приложения на Erlang / Максим Лапшин (Erlyvideo)
Отладка производительности приложения на Erlang / Максим Лапшин (Erlyvideo)
 
Бинарные (файловые) хранилища- страшная сказка с мрачным концом
Бинарные (файловые) хранилища- страшная сказка с мрачным концомБинарные (файловые) хранилища- страшная сказка с мрачным концом
Бинарные (файловые) хранилища- страшная сказка с мрачным концом
 
А. Аксенов "Как мы разрабатываем Сфинкс", DUMP-2014
А. Аксенов "Как мы разрабатываем Сфинкс", DUMP-2014А. Аксенов "Как мы разрабатываем Сфинкс", DUMP-2014
А. Аксенов "Как мы разрабатываем Сфинкс", DUMP-2014
 
Евгения Фирсова "Выкладка вёрстки — просто, быстро, безопасно"
Евгения Фирсова "Выкладка вёрстки — просто, быстро, безопасно"Евгения Фирсова "Выкладка вёрстки — просто, быстро, безопасно"
Евгения Фирсова "Выкладка вёрстки — просто, быстро, безопасно"
 
My talk at YouCon Saratov 2016
My talk at YouCon Saratov 2016My talk at YouCon Saratov 2016
My talk at YouCon Saratov 2016
 

Más de Fwdays

"How Preply reduced ML model development time from 1 month to 1 day",Yevhen Y...
"How Preply reduced ML model development time from 1 month to 1 day",Yevhen Y..."How Preply reduced ML model development time from 1 month to 1 day",Yevhen Y...
"How Preply reduced ML model development time from 1 month to 1 day",Yevhen Y...Fwdays
 
"GenAI Apps: Our Journey from Ideas to Production Excellence",Danil Topchii
"GenAI Apps: Our Journey from Ideas to Production Excellence",Danil Topchii"GenAI Apps: Our Journey from Ideas to Production Excellence",Danil Topchii
"GenAI Apps: Our Journey from Ideas to Production Excellence",Danil TopchiiFwdays
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
"What is a RAG system and how to build it",Dmytro Spodarets
"What is a RAG system and how to build it",Dmytro Spodarets"What is a RAG system and how to build it",Dmytro Spodarets
"What is a RAG system and how to build it",Dmytro SpodaretsFwdays
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
"Distributed graphs and microservices in Prom.ua", Maksym Kindritskyi
"Distributed graphs and microservices in Prom.ua",  Maksym Kindritskyi"Distributed graphs and microservices in Prom.ua",  Maksym Kindritskyi
"Distributed graphs and microservices in Prom.ua", Maksym KindritskyiFwdays
 
"Rethinking the existing data loading and processing process as an ETL exampl...
"Rethinking the existing data loading and processing process as an ETL exampl..."Rethinking the existing data loading and processing process as an ETL exampl...
"Rethinking the existing data loading and processing process as an ETL exampl...Fwdays
 
"How Ukrainian IT specialist can go on vacation abroad without crossing the T...
"How Ukrainian IT specialist can go on vacation abroad without crossing the T..."How Ukrainian IT specialist can go on vacation abroad without crossing the T...
"How Ukrainian IT specialist can go on vacation abroad without crossing the T...Fwdays
 
"The Strength of Being Vulnerable: the experience from CIA, Tesla and Uber", ...
"The Strength of Being Vulnerable: the experience from CIA, Tesla and Uber", ..."The Strength of Being Vulnerable: the experience from CIA, Tesla and Uber", ...
"The Strength of Being Vulnerable: the experience from CIA, Tesla and Uber", ...Fwdays
 
"[QUICK TALK] Radical candor: how to achieve results faster thanks to a cultu...
"[QUICK TALK] Radical candor: how to achieve results faster thanks to a cultu..."[QUICK TALK] Radical candor: how to achieve results faster thanks to a cultu...
"[QUICK TALK] Radical candor: how to achieve results faster thanks to a cultu...Fwdays
 
"[QUICK TALK] PDP Plan, the only one door to raise your salary and boost care...
"[QUICK TALK] PDP Plan, the only one door to raise your salary and boost care..."[QUICK TALK] PDP Plan, the only one door to raise your salary and boost care...
"[QUICK TALK] PDP Plan, the only one door to raise your salary and boost care...Fwdays
 
"4 horsemen of the apocalypse of working relationships (+ antidotes to them)"...
"4 horsemen of the apocalypse of working relationships (+ antidotes to them)"..."4 horsemen of the apocalypse of working relationships (+ antidotes to them)"...
"4 horsemen of the apocalypse of working relationships (+ antidotes to them)"...Fwdays
 
"Reconnecting with Purpose: Rediscovering Job Interest after Burnout", Anast...
"Reconnecting with Purpose: Rediscovering Job Interest after Burnout",  Anast..."Reconnecting with Purpose: Rediscovering Job Interest after Burnout",  Anast...
"Reconnecting with Purpose: Rediscovering Job Interest after Burnout", Anast...Fwdays
 
"Mentoring 101: How to effectively invest experience in the success of others...
"Mentoring 101: How to effectively invest experience in the success of others..."Mentoring 101: How to effectively invest experience in the success of others...
"Mentoring 101: How to effectively invest experience in the success of others...Fwdays
 
"Mission (im) possible: How to get an offer in 2024?", Oleksandra Myronova
"Mission (im) possible: How to get an offer in 2024?",  Oleksandra Myronova"Mission (im) possible: How to get an offer in 2024?",  Oleksandra Myronova
"Mission (im) possible: How to get an offer in 2024?", Oleksandra MyronovaFwdays
 
"Why have we learned how to package products, but not how to 'package ourselv...
"Why have we learned how to package products, but not how to 'package ourselv..."Why have we learned how to package products, but not how to 'package ourselv...
"Why have we learned how to package products, but not how to 'package ourselv...Fwdays
 
"How to tame the dragon, or leadership with imposter syndrome", Oleksandr Zin...
"How to tame the dragon, or leadership with imposter syndrome", Oleksandr Zin..."How to tame the dragon, or leadership with imposter syndrome", Oleksandr Zin...
"How to tame the dragon, or leadership with imposter syndrome", Oleksandr Zin...Fwdays
 

Más de Fwdays (20)

"How Preply reduced ML model development time from 1 month to 1 day",Yevhen Y...
"How Preply reduced ML model development time from 1 month to 1 day",Yevhen Y..."How Preply reduced ML model development time from 1 month to 1 day",Yevhen Y...
"How Preply reduced ML model development time from 1 month to 1 day",Yevhen Y...
 
"GenAI Apps: Our Journey from Ideas to Production Excellence",Danil Topchii
"GenAI Apps: Our Journey from Ideas to Production Excellence",Danil Topchii"GenAI Apps: Our Journey from Ideas to Production Excellence",Danil Topchii
"GenAI Apps: Our Journey from Ideas to Production Excellence",Danil Topchii
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
"What is a RAG system and how to build it",Dmytro Spodarets
"What is a RAG system and how to build it",Dmytro Spodarets"What is a RAG system and how to build it",Dmytro Spodarets
"What is a RAG system and how to build it",Dmytro Spodarets
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
"Distributed graphs and microservices in Prom.ua", Maksym Kindritskyi
"Distributed graphs and microservices in Prom.ua",  Maksym Kindritskyi"Distributed graphs and microservices in Prom.ua",  Maksym Kindritskyi
"Distributed graphs and microservices in Prom.ua", Maksym Kindritskyi
 
"Rethinking the existing data loading and processing process as an ETL exampl...
"Rethinking the existing data loading and processing process as an ETL exampl..."Rethinking the existing data loading and processing process as an ETL exampl...
"Rethinking the existing data loading and processing process as an ETL exampl...
 
"How Ukrainian IT specialist can go on vacation abroad without crossing the T...
"How Ukrainian IT specialist can go on vacation abroad without crossing the T..."How Ukrainian IT specialist can go on vacation abroad without crossing the T...
"How Ukrainian IT specialist can go on vacation abroad without crossing the T...
 
"The Strength of Being Vulnerable: the experience from CIA, Tesla and Uber", ...
"The Strength of Being Vulnerable: the experience from CIA, Tesla and Uber", ..."The Strength of Being Vulnerable: the experience from CIA, Tesla and Uber", ...
"The Strength of Being Vulnerable: the experience from CIA, Tesla and Uber", ...
 
"[QUICK TALK] Radical candor: how to achieve results faster thanks to a cultu...
"[QUICK TALK] Radical candor: how to achieve results faster thanks to a cultu..."[QUICK TALK] Radical candor: how to achieve results faster thanks to a cultu...
"[QUICK TALK] Radical candor: how to achieve results faster thanks to a cultu...
 
"[QUICK TALK] PDP Plan, the only one door to raise your salary and boost care...
"[QUICK TALK] PDP Plan, the only one door to raise your salary and boost care..."[QUICK TALK] PDP Plan, the only one door to raise your salary and boost care...
"[QUICK TALK] PDP Plan, the only one door to raise your salary and boost care...
 
"4 horsemen of the apocalypse of working relationships (+ antidotes to them)"...
"4 horsemen of the apocalypse of working relationships (+ antidotes to them)"..."4 horsemen of the apocalypse of working relationships (+ antidotes to them)"...
"4 horsemen of the apocalypse of working relationships (+ antidotes to them)"...
 
"Reconnecting with Purpose: Rediscovering Job Interest after Burnout", Anast...
"Reconnecting with Purpose: Rediscovering Job Interest after Burnout",  Anast..."Reconnecting with Purpose: Rediscovering Job Interest after Burnout",  Anast...
"Reconnecting with Purpose: Rediscovering Job Interest after Burnout", Anast...
 
"Mentoring 101: How to effectively invest experience in the success of others...
"Mentoring 101: How to effectively invest experience in the success of others..."Mentoring 101: How to effectively invest experience in the success of others...
"Mentoring 101: How to effectively invest experience in the success of others...
 
"Mission (im) possible: How to get an offer in 2024?", Oleksandra Myronova
"Mission (im) possible: How to get an offer in 2024?",  Oleksandra Myronova"Mission (im) possible: How to get an offer in 2024?",  Oleksandra Myronova
"Mission (im) possible: How to get an offer in 2024?", Oleksandra Myronova
 
"Why have we learned how to package products, but not how to 'package ourselv...
"Why have we learned how to package products, but not how to 'package ourselv..."Why have we learned how to package products, but not how to 'package ourselv...
"Why have we learned how to package products, but not how to 'package ourselv...
 
"How to tame the dragon, or leadership with imposter syndrome", Oleksandr Zin...
"How to tame the dragon, or leadership with imposter syndrome", Oleksandr Zin..."How to tame the dragon, or leadership with imposter syndrome", Oleksandr Zin...
"How to tame the dragon, or leadership with imposter syndrome", Oleksandr Zin...
 

Vsevolod Solovyov "How to debug. Everything"