Comments (20)
@zerkms Yes, I agree, still investigating it. Only services from this bundle are loading this slow.
from two-factor-bundle.
Here are the latest findings. Making scheb_two_factor.provider_registry
service lazy lowers down latency by double. Making scheb_two_factor.trusted_filter
makes latency go away, no services from this bundle are shown in Blackfire profile, which means bottleneck is gone.
@scheb I think requiring ocramius/proxy-manager
is totally worth it.
from two-factor-bundle.
Release will be published as soon as Travis build greenlights the change.
from two-factor-bundle.
The 25ms seem a little bit too high for me for just fetching a service. DIC in prod should be able to do that way faster. Did you measure those values in a "dev" or a "prod" environment? Do you have some op-code cache enabled, either APC or native PHP7 op-code cache?
Anyways, there IS room for improvment.
I think a major improvment would be if scheb_two_factor.provider_registry
would lazy-load the authentication provider services, because it only needs the service instance, when two-factor authentication has to be executed. But I wouldn't like to require the ocramius/proxy-manager
on the bundle-level. Using that is more of a application-level decision, that the user has to do, and I don't want people force using it. So a simple "AuthenticationProviderFactory" that fetches the service from DIC on-demand would be the best solution im my opinion.
from two-factor-bundle.
@scheb Yes, it is too high, that's why I'm posting. Other services are fetched way faster. It's from Blackfire profile done on prouduction with op-code cache enabled. Thanks.
from two-factor-bundle.
So, what exactly consumes those 25ms?
from two-factor-bundle.
@zerkms Fetching service from container:
from two-factor-bundle.
Right, but what exactly takes so long? 26ms is A LOT. Nothing but few objects are instantiated there.
On my symfony projects some of entire requests (from the first request byte to the last response byte) take less than that.
I would still suggest to find the real problem before trying to optimise it, since it looks suspicious.
from two-factor-bundle.
@scheb Awesome, thanks! 👍
from two-factor-bundle.
Well, I checked code and I'm not convinced that it should have been implemented like that.
The current solution mitigates the consequences but does not solve the root of the problems (since the roots haven't been detected).
Adding lazy
to something that looks like slow but is not proven to be the problem - is crazy.
Especially that - when exclude_pattern
is used it is not to be instantiated at all, and when it's not - the service must be instantiated anyway. So overall - the proposed solution made the performance worse (since the proxy is not free).
My best guess would be that it's other dependencies that scheb_two_factor.provider_registry
depends on are slow, and making it lazy
just postpones their initialisation. So - you just made it looking like it became faster, while the load was just spread over other services.
UPD: and after some debugging I'm even more confident that what I said above is true and that "the solution" solves nothing just hides the real problem somewhere else. Some candidates that do some heavy lifting are templating
and perhaps the doctrine.
from two-factor-bundle.
@zerkms I agree except that it does not solves nothing. It solves slowness on all pages that are not authentication. This is a huge win for me. I agree that it should be investigated further and optimize auth pages.
from two-factor-bundle.
@umpirsky well, lazy
does not prevent the service from loading, it just postpones it. So it is still instantiated, just slightly later. My point is that the problem was shifted to other place.
Did you get instant improvement of performance of 26ms everywhere? So every page now loads 26ms faster? You should not have.
It solves slowness on all pages that are not authentication.
It's not possible - it is still instantiated.
from two-factor-bundle.
@zerkms No, because it's not used during request that does not trigger 2FA. So it's not instantiated.
from two-factor-bundle.
@umpirsky have you tried to confirm that with a debugger?
https://github.com/scheb/two-factor-bundle/blob/master/Security/TwoFactor/EventListener/RequestListener.php#L84 this line is executed for every request that is not ignored using excludePattern
(and that should be every url that is protected by symfony firewalls).
Otherwise the
that does not trigger 2FA
needs some clarification.
from two-factor-bundle.
@zerkms Yes, that line is executed, but not the scheb_two_factor.trusted_filter
.
from two-factor-bundle.
$this->authHandler
on that line is defined as <argument type="service" id="scheb_two_factor.trusted_filter" />
(at https://github.com/scheb/two-factor-bundle/blob/master/Resources/config/listeners.xml#L18)
Have you tried to run a debugger and confirm what you say?
I'm not in the office now so I cannot take a screenshot of a stack trace, not sure why you don't simply try it and see :-( Seriously, we are wasting time: performance optimisation is about precise stuff: everything must be proven, there must be no place for suggestions and guesses (and jeez - especially random changes, which that change surely is). I have made a statement that I have checked and confirmed with a debugger. It's not constructive if I spend dozens of comments more begging to revert a useless change (that not only makes nothing faster but slower for most of use cases this bundle was designed for).
from two-factor-bundle.
@zerkms You are right, I will check again when I find some time and post results here. Now, I only remember that moving this to lazy fixed the issue for me.
from two-factor-bundle.
Now, I only remember that moving this to lazy fixed the issue for me.
It could not have - lazy
does not reduce the amount of job to be done (it actually increases both cpu and memory footprint in case if the service is used, and it is used in almost every request).
So I believe it is either placebo or some issues with capturing the performance metrics.
from two-factor-bundle.
Issue is still here, working on a fix...
from two-factor-bundle.
from two-factor-bundle.
Related Issues (20)
- Use multiple interfaces, one with JWT and API HOT 8
- Resent email authentication code HOT 8
- Type error: Too few arguments to function Scheb\TwoFactorBundle\Controller\FormController::__construct(), 0 passed HOT 2
- Two-factor authentication form is not shown after login HOT 16
- LogoutHandlerInterface is deprecated since Symfony 5.1 HOT 6
- No Two factor form after logging in (no redirect) HOT 7
- User Deprecated HOT 1
- Authenticate two factor in one request (with json_login) HOT 4
- Called providers session value is never unset HOT 4
- How to use the two factor auth in combination with manual authentication HOT 3
- Doesn't work in PROD works in DEV HOT 2
- 2FA by api + jwt HOT 8
- FatalThrowableError in RememberMeServicesDecoratorCompilerPass HOT 4
- impossible to go through page 2fa during login HOT 8
- How to change default path 2fa HOT 1
- Infinite login loop when updating user credentials HOT 2
- Login via email failed HOT 7
- Not prompted for Google Authenticator code on login HOT 14
- 2fa form is not being shown HOT 16
- Session id changes after 2fa succeed. And UsernamePasswordToken cannot be loaded from Redis. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from two-factor-bundle.