Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Road to SRE culture in a small company
Search
Sobolev Nikita
February 28, 2019
Programming
1
130
Road to SRE culture in a small company
Sobolev Nikita
February 28, 2019
Tweet
Share
More Decks by Sobolev Nikita
See All by Sobolev Nikita
PythoNN: Василий Рябов – "Парсинг бинарных данных с помощью ctypes, или пишем на питоне как на Си"
sobolevn
0
87
GitHub Planet - OpenSource
sobolevn
0
150
Polymorphism and Typeclasses
sobolevn
2
96
New GitHub Features
sobolevn
0
32
Problems of static analysis in Python
sobolevn
0
53
Announcing typed-linter
sobolevn
0
190
About GitHub Stars
sobolevn
0
140
Typing Django
sobolevn
0
150
Functional programming for beginners
sobolevn
0
210
Other Decks in Programming
See All in Programming
Kotlin Multiplatform at Stable and Beyond (Android Makers 2024)
zsmb
0
550
Compose-View Interop in Practice (mDevCamp 2024)
stewemetal
0
170
仕様と実装で学ぶOpenTelemetry
drumato
1
130
Next.js App Router
quramy
13
2.1k
The Cutting Edge Of Versioning (LambdaConf 2024)
chriskrycho
0
230
Three ways to use AI on Android: The Good, the Bad and the Ugly
marxallski
0
110
Go製Webアプリケーションのエラーとの向き合い方大全、あるいはやっぱりスタックトレース欲しいやん / Kyoto.go #50
utgwkk
6
1.9k
冗長なエラーログを削減し、スタックトレースを手に入れる / Reducing Verbose Error Logs and Obtaining Stack Traces
upamune
0
1.1k
Ruby Pattern Matching
bkuhlmann
0
940
Behind VS Code Extensions for JavaScript / TypeScript Linnting and Formatting
unvalley
6
1.3k
大規模UIKitベースアプリへのTCAの段階的導入/gradual-adoption-of-tca-in-a-large-scale-uikit-based-app
takehilo
2
210
使ってみよう Azure AI Document Intelligence
kosmosebi
2
370
Featured
See All Featured
Optimising Largest Contentful Paint
csswizardry
13
2.4k
The Power of CSS Pseudo Elements
geoffreycrofte
62
5k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
21
1.9k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
245
20k
Raft: Consensus for Rubyists
vanstee
133
6.3k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
501
140k
The World Runs on Bad Software
bkeepers
PRO
61
6.7k
The Invisible Side of Design
smashingmag
294
49k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
660
120k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
323
20k
It's Worth the Effort
3n
180
27k
Navigating Team Friction
lara
179
13k
Transcript
None
Никита Соболев github.com/sobolevn
У меня пока нет SRE. Как?
None
wemake.services/meta Repeatable Software Development Process
None
1. Задача 2. Контроль 3. Деньги
1. Задача 2. Контроль 3. Деньги
None
None
None
None
None
Будет ли кто–то будет хоть что–то делать?
1. Задача 2. Контроль 3. Деньги
sobolevn.me/2018/12/blameless-environment Blameless environment
К технике
Автоматизируем? •Чем строже, тем лучше •Чем чаще, тем лучше •Чем
хрупче, тем лучше
CI / CD • Блокирующий • Полный, но быстрый •
Повторяемый
ХО ХО ХО
Типы тестов • Доктесты • Юнит • Интеграционные • E2E
• Snapshots • Property-based • Мутационные • Контрактные • Регрессионные • Ручные
Required test coverage of 100% reached. Total coverage: 100.00% ===========
8408 passed, 2 skipped in 50.33 seconds =============
github.com/wemake-services/wemake-python- styleguide Линтеры!
None
Есть файл? Нужен линтер!
dotenv-linter polint dennis eslint stylelint hadolint shellcheck yamllint flake8 layer-linter
xenon doc8 markdown-lint remark-lint mypy credo commitlint gherkin-lint
И плагины! vue json html pyi typescript flow jsdoc docker-compose
И конфигурация!
None
IaC • github.com/ansible/ansible • github.com/ansible/molecule • github.com/ansible/ansible-lint
Review Apps docs.gitlab.com/ee/ci/review_apps
Runtime окружение • Одно окружение: очевидный Docker • Одни версии:
не latest • Одни настройки: 12 factor app • Один способ запустить
Dependencies • Детерминированные • Запиненные • Безопасные • Обновляемые
None
Мониторим • Ресурсы • Логи • Ошибки
Три правила Sentry • Используйте • Выкиньте все лишнее •
Интегрируйте с таск–трекером
None
None
Поговорим про код
None
Версионируйте! • Обновляйте и валидируйте спеку • Тестируйте спеку! pypi.org/project/swagger-conformance
client = Client('your.app/swagger.json') strategy_factory = StrategyFactory() operation = client.api.endpoints['/pet']['put'] strategy
= operation.strategy(strategy_factory) print(strategy.example())
{ 'body':{ 'id':110339, 'name':'\U00052ea5\x9d\ua79d\x92\x13\U000f7c436', 'photoUrls':[ '\ua9d9\U0003fb3a\x13\U00025c1c\U000974a8\u3497\n', "\U000b38a4>*\u6683'\U0002cd8f\x0f\n" ], 'tags':[ {
'id':-172930, 'name':'\U000286df\u04dc\U00033563\U00055ba8\x89H' } ] } }
Используйте commitizen
None
None
None
Угомоните хаос • Логика должна быть логичной (DDD) • Пишите
спеки (BDD)
sobolevn.me/2019/02/engineering-guide-to- user-stories
pypi.org/project/pytest-bdd
layer-linter.readthedocs.io Логика – как хороший пирог
My Domain: containers: - accounts - webhooks layers: - usecases
- services - entities
Рефакторите • Рефакторите • Думайте над дизайном (TDD) pypi.org/project/pytest-testmon
None
Типизируйте очень строго!
_ValidUser = NewType('_ValidUser', User) def validate_user(user: User) -> _ValidUser: ...
def persist(user: _ValidUser) -> None: ...
Запросы aka IO
images = Image.objects.filter( category__name='Cats', ) for image in images: print(image.category.name)
Падать на N+1 github.com/jmcarp/nplusone
requests.get('https://my.api/v1/users')
None
Уберите лишние exception'ы github.com/dry-python/returns
def fetch_user_profile(user_id: int) -> 'User': response = requests.get(f'/users/{user_id}') response.raise_for_status() return
response.json()
Таски, очереди, треды, корутины, etc
Timeout'ы и лимиты!
OperationalError: database is locked DATABASES = { 'default': { 'ENGINE':
'django.backends.postgres', 'OPTIONS': { 'timeout': 20, } } }
На тесты тоже нужны таймауты pypi.org/project/pytest-timeout
Как жить? • Мониторинг • Healthchecks • Двойной кот–ревью
None
None
None
Backward incompatible migrations • Думайте головой • Используйте несколько миграций
• Тестируйте pypi.org/project/django-migration-linter
Лайфхаки
Используйте хорошие языки
Используйте нормальную ОС nixos.org
Отдайте инфраструктуру, не нужна она вам
Вините систему, а не людей
Вывод IO
Почитать • sobolevn.me/2019/02/python-exceptions-considered-an- antipattern • sobolevn.me/2019/02/engineering-guide-to-user-stories • engineering.skybettingandgaming.com/2016/02/02/how-we- release-so-frequently/ •
amberonrails.com/move-fast-dont-break-your-api/ • 2factor.net/ru/ • github.com/conventional-changelog/conventional- changelog
Попробовать! • github.com/wemake-services/wemake-django- template • github.com/wemake-services/wemake-vue-template
Присылайте идеи! github.com/sobolevn sobolevn.me