Skip to content

[DependencyInjection] Fix loading all env vars from secrets when only a subset is needed #53631

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

Merged
merged 1 commit into from
Jan 29, 2024

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Jan 24, 2024

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #53429
License MIT

As spotted in the linked issue, we have a significant performance issue when loading env vars.
The issue is that when one env var is needed but not defined, we still decrypt all existing env vars.
This also means we have a scalability issue when the number of env vars increases.
Since this happens usually on every single requests, this can burn the CPU.

The solution implemented in this PR is to use lazy strings to load env vars so that we don't decrypt them unless they are actually needed.

@carsonbot carsonbot added this to the 6.4 milestone Jan 24, 2024
@nicolas-grekas nicolas-grekas changed the title Secrets lazy [DependencyInjection] Fix loading all env vars from secrets when only a subset is needed Jan 24, 2024
@carsonbot carsonbot changed the title [DependencyInjection] Fix loading all env vars from secrets when only a subset is needed Fix loading all env vars from secrets when only a subset is needed Jan 24, 2024
@carsonbot carsonbot changed the title Fix loading all env vars from secrets when only a subset is needed [DependencyInjection] Fix loading all env vars from secrets when only a subset is needed Jan 24, 2024
@symfony symfony deleted a comment from carsonbot Jan 24, 2024
@nicolas-grekas nicolas-grekas force-pushed the secrets-lazy branch 3 times, most recently from a01072e to 566045e Compare January 24, 2024 23:58
@nicolas-grekas nicolas-grekas merged commit 84f5bdc into symfony:6.4 Jan 29, 2024
@fabpot fabpot mentioned this pull request Jan 31, 2024
@nicolas-grekas nicolas-grekas deleted the secrets-lazy branch January 31, 2024 07:31
@fabpot fabpot mentioned this pull request Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants