Upgrade to Pro — share decks privately, control downloads, hide ads and more …

[SnowOne 2024] Егор Зиборов: Java, сделай мне больно!

[SnowOne 2024] Егор Зиборов: Java, сделай мне больно!

Все мы пишем код, используем новые подходы и технологии в работе, но иногда в продакшене все оборачивается совсем неожиданным образом.

Прибегают Ops-инженеры с проблемами, о которых мы иногда даже задуматься не могли во время дизайна и написания сервиса. Почему бы им не помочь в разборе проблем?

Спикер на примерах расскажет о неочевидных ошибках, которые ловили в продакшене, как искали их причины и как их можно было бы избежать.

jugnsk

May 01, 2024
Tweet

More Decks by jugnsk

Other Decks in Programming

Transcript

  1. СБОЛ жи есть Активных клиентов в месяц MAU 80млн 4000rps

    Количество одновременных входов в приложение 6
  2. Disclaimer О чем? • Про опыт • Про ресерч •

    Про боль Для кого? • Для разработчиков • Для Ops инженеров 9
  3. 28

  4. StackOverflow в Java EntryFrame Frame 1 Frame 2 Frame 3

    Frame 4 Yellow Zone Red Zone XSS Fatal JVM error StackOverflowError 30
  5. Java решает! (с jdk 9) JEP 270: Reserved Stack Areas

    for Critical Sections Reserve extra space on thread stacks for use by critical sections, so that they can complete even when stack overflows occur. https://pangin.pro/posts/stack-overflow-handling EntryFrame Frame 1 Frame 2 Frame 3 Reserved Zone Yellow Zone Red Zone Fatal JVM error StackOverflowError StackOverflowError ПОСЛЕ выхода из секции 31
  6. Make Java Great Again JDK-8318888 - ReentrantLock results in a

    locked state after StackOverflowError JDK-8319090 - StackOverflow from ThreadLocal.set might shadow the root cause 35
  7. • Нет StackOverFlow – нет проблем! • Мониторь StackOverflowError и

    OutOfMemoryError в системе • Добавлять? –XX:AbortVMOnException=java.lang.StackOverflowError Мораль 42
  8. У вас и БД есть? БД Зачем? o Кэш o

    Мастер-данные СБОЛ КАРТЫ ВКЛАДЫ КРЕДИТЫ 44
  9. StandIn Что важно? o Есть резервный блок, без нагрузки o

    В любой момент можно перевести всю нагрузку на него Активный блок Резервный блок NGINX БД БД Репликации 45
  10. И вот однажды… Переключение в StandBy под нагрузкой Не прогретые

    DataSource’ы Массовое создание Connection’ов Logon Storm на БД Что произошло? 47
  11. 48

  12. 49

  13. Как же так…? WebSphere::Minimum connections This property defines the minimum

    number of physical connections that will be kept open in the free pool. When the JVM is started, WAS does not automatically create the number of connections that is defined by this property. HikariCP::minimumIdle 🔢minimumIdle This property controls the minimum number of idle connections that HikariCP tries to maintain in the pool. If the idle connections dip below this value and total connections in the pool are less than maximumPoolSize, HikariCP will make a best effort to add additional connections quickly and efficiently. However, for maximum performance and responsiveness to spike demands, we recommend not setting this value and instead allowing HikariCP to act as a fixed size connection pool. Default: same as maximumPoolSize 51
  14. Все работает! Node1 Node2 NodeN External System gRPC Connect gRPC

    Connect gRPC Connect Имеем: o для всех нод одна точка подключения (LoadBalancer) – ничего не знаем о его структуре o каждая нода держит один connection 63
  15. Или нет… Node1 Node2 NodeN External System gRPC Connect gRPC

    Connect gRPC Connect Что-то случилось! o На одной из нод начались таймауты на 100% запросов Что делаем? Конечно, ребутаем! 64
  16. Одним ребутом сыт не будешь Node1 Node2 NodeN gRPC Connect

    gRPC Connect gRPC Connect LoadBalancer POD1 POD2 POD3 65
  17. Одним ребутом сыт не будешь Node1 Node2 NodeN gRPC Connect

    gRPC Connect gRPC Connect LoadBalancer POD1 POD2 POD3 POD2 POD3 66
  18. Одним ребутом сыт не будешь Node1 Node2 NodeN gRPC Connect

    gRPC Connect gRPC Connect LoadBalancer POD1 POD2 POD3 POD2 POD3 67
  19. gRPC ли? Node1 Node2 NodeN HTTP Connect HTTP Connect HTTP

    Connect LoadBalancer POD1 POD2 POD3 POD2 POD3 71
  20. Выводы 1. Что такое СБОЛ 2. StackOverflow в finally блоке

    3. Важность проверки переключения на StandBy 4. Важность reconnect’a внутри ConnectionPool’ов 74