在我的一个 symfony 项目中,我最近遇到了巨大的性能问题,性能问题似乎隐藏在“Symfony\Bundle\SecurityBundle\Debug\TraceableFirewallListener”之后,恰好在“Symfony\Component\Security\Http\Firewall \上下文监听器”。
以下是我的开发服务器和实时服务器的屏幕截图 - 服务器规格符合要求,我绝对确定问题不在服务器背后,因为其他项目在类似服务器上运行良好。
我将不胜感激有关如何进一步解决或调试此问题的任何提示,因为我束手无策。Symfony 版本是 4.0.1,更新到最新版本并没有解决问题。
编辑:使用秒表组件进一步调试让我得出结论,加载时间来自 Symfony/Bridge/Doctrine/Security/User/EntityUserProvider,方法“refreshUser”,第 93 行,调用“$refreshedUser = $repository- >查找($id);" 在最大的部分,如 2681 毫秒中的 2647 毫秒。不过,我不知道从现在起该去哪里。
我的安全配置:
security:
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
encoders:
App\Entity\User:
algorithm: bcrypt
legacy_encoder:
algorithm: md5
encode_as_base64: false
iterations: 1
providers:
in_memory: { memory: ~ }
db_provider:
entity:
class: App\Entity\User
property: username
role_hierarchy:
ROLE_USER_MO: ROLE_USER
ROLE_USER_WKB: ROLE_USER
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
#pattern: ^/
#http_basic: ~
anonymous: ~
provider: db_provider
user_checker: App\Security\UserChecker
logout:
path: /logout
target: /login
form_login:
login_path: login
check_path: login
access_control:
#- { path: ^/, roles: ROLE_USER }
#- { path: ^/login, allow_if: "is_anonymous() and !is_authenticated()" }
- { path: ^/motivwelten, roles: ROLE_USER }
- { path: ^/services/.*, roles: ROLE_USER }
- { path: ^/shop, roles: ROLE_USER }
- { path: ^/shop/.*, roles: ROLE_USER }
- { path: ^/user/.*, roles: ROLE_USER }
- { path: ^/password-forgotten, allow_if: "is_anonymous() and !is_authenticated()" }
- { path: ^/password-forgotten/.*, allow_if: "is_anonymous() and !is_authenticated()" }
- { path: ^/downloads, roles: ROLE_USER }
erase_credentials: false



