-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Task 8 [Kirill Usanov] #28
Open
Exterm1nate
wants to merge
2
commits into
hardcode-dev:master
Choose a base branch
from
Exterm1nate:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# See https://help.github.com/articles/ignoring-files for more about ignoring files. | ||
# | ||
# If you find yourself ignoring temporary files generated by your text editor | ||
# or operating system, you probably want to add a global ignore instead: | ||
# git config --global core.excludesfile '~/.gitignore_global' | ||
|
||
#Jetbrains Tools | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# О проекте | ||
|
||
Проект - _**админка**_, совмещенная с _**личным кабинетом**_ (_**ЛК**_) пользователей. | ||
|
||
Основной задачей _**ЛК**_ является предоставление пользователям возможности купить подписку на софт компании, | ||
управлять этими подписками и прочее. | ||
|
||
_**Админка**_ же создана для хранения информации о пользователях, их подписках, счетах, платежах и так далее. | ||
|
||
Разрабатывается это все примерно года с 2013, большинство ужасного легаси кода уже выпилено, | ||
но некоторые его отголоски доносятся до сих пор. | ||
|
||
Префоманс, в принципе, всех устраивает: | ||
в _**ЛК**_ пользователи заходят не так часто, | ||
в _**админке**_ сидит не больше 50 человек. | ||
Отдельные страницы (например, с какими-то тяжелыми отчетами) могут открываться достаточно долго, | ||
но они не слишком востребованы в работе (от силы несколько раз в неделю-месяц открываются), так что проблемой это не является. | ||
|
||
До прохождения курса были прикручены некоторые стандартные графики для `Grafana` и `NewRelic`. | ||
Во время прохождения курса я также добавил `PgHero` и `rack-mini-profiler` для прода, | ||
но это скорее не из необходимости оптимизации, а с заделом на будущее (ну и ради интереса). | ||
|
||
Работаю на проекте ~ 9 месяцев. | ||
|
||
# Оптимизация | ||
|
||
Но доколе оптимизировать что-то нужно, воспользуемся имеющимися средставами. | ||
|
||
## PgHero | ||
|
||
Начать я решил с `PgHero`. | ||
За полтора месяца работы он успел пособирать статистику по проекту, потому воспользуюсь ей. | ||
|
||
_Suggested Indexes_ рекомендует добавить 3 индекса для запросов, которые вызывались 50-100 раз | ||
(не совсем понимаю, за какой промежуток времени, но даже если за день - это очень мало) и выполнялись в среднем 20-50 мс. | ||
Такая оптимизация не будет стоить ни времени, ни занятого места в БД под эти индексы, так что добавлять я их не буду. | ||
|
||
А вот в _Queries_ в топе висит очень жирный запрос - среднее время выполнения 8 секунд, | ||
занимает 22% дневного времени загрузки. Правда, он выполняется асинхронно через `Cron`, | ||
но такое в любом случае стоит оптимизировать. | ||
|
||
 | ||
|
||
Добавил индекс, подождал выполнения `Cron` джобы, и вуаля: | ||
|
||
 | ||
|
||
Один индекс изменил время выполнения запроса с 8_500 до 200 мс - очень хороший результат. | ||
|
||
## Тесты | ||
|
||
С коллегой решили задаться также оптимизацией test suite для улучшения DX и уменьшения времени CI. | ||
Прикрутили разные полезности из предыдущей лекции, по-быстрому заменили что в глаза бросалось | ||
и получился такой результат прогона CI: | ||
|
||
До оптимизации: | ||
|
||
 | ||
|
||
После оптимизации: | ||
|
||
 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
Пранируем в будущем добавить отправку времени прогона CI в InfluxDB, чтобы следить за деградацией. | ||
|
||
## Бонус | ||
|
||
Переписывал недавно одну из страниц проекта с React на Stimulus, заодно выкинув его целиком вместе с рядом зависимостей, | ||
т.к. больше оно нигде не использовалось. | ||
Получилось так, что билд с прекомпиляцией ассетов стал проходить на минуту-полторы быстрее, | ||
да и эта страница стала грузиться по ощущениям несколько быстрее (но метрики с этого я не брал, так что не понятно насколько именно). | ||
Цели оптимизировать не было, но результат оказался неплохим. | ||
Порой просто удаление ненужных вещей из проекта может существенно увеличить производительность в каком-нибудь месте. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
До оптимизации: | ||
|
||
 | ||
|
||
После оптимизации: | ||
|
||
 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
изи 40x