Symfony+API Platform请求执行耗时超4秒,需提供哪些排查信息?
Symfony + API Platform 请求执行时间超4秒,需补充哪些信息协助排查?
已提供信息
截图说明
请求执行时间相关性能截图
尝试过的操作
查找过类似性能问题案例,但因场景过于个性化,未找到有效解决方案
app.ini 配置
variables_order = EGPCS expose_php = 0 date.timezone = UTC apc.enable_cli = 1 session.use_strict_mode = 1 zend.detect_unicode = 0 memory_limit = 2048M realpath_cache_size = 4096K realpath_cache_ttl = 600 opcache.interned_strings_buffer = 16 opcache.max_accelerated_files = 20000 opcache.memory_consumption = 256 opcache.enable_file_override = 1
security.yaml 配置
security: enable_authenticator_manager: true password_hashers: Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto' providers: app_user_provider: mongodb: class: App\Document\User property: login firewalls: profiler: pattern: ^/(_profiler|_wdt) http_basic: realm: Secured Area dev: pattern: ^/(css|images|js)/ security: false api: pattern: ^/ stateless: true provider: app_user_provider lazy: true entry_point: jwt json_login: check_path: login_check username_path: login password_path: password success_handler: lexik_jwt_authentication.handler.authentication_success failure_handler: lexik_jwt_authentication.handler.authentication_failure jwt: ~ refresh_jwt: check_path: refresh_token role_hierarchy: ROLE_ADMIN: ROLE_USER access_control: - { path: ^/admin, roles: ROLE_ADMIN } - { path: ^/_profiler, roles: ROLE_USER } - { path: ^/register, roles: PUBLIC_ACCESS } - { path: ^/docs, roles: PUBLIC_ACCESS } when@test: security: password_hashers: Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: algorithm: auto cost: 4 time_cost: 3 memory_cost: 10
需补充的排查信息
- 环境版本:Symfony、API Platform、PHP、MongoDB(及ODM)的具体版本号;服务器操作系统、Web服务器(Nginx/Apache)版本
- 请求详情:是否所有请求都慢?还是特定接口(比如列表查询、关联数据加载)慢?请求的URL、请求方法、参数示例
- 性能分析数据:
- Symfony Profiler的Timeline面板中耗时Top5的事件详情(如数据库查询、服务初始化、JWT验证等)
- MongoDB慢查询日志(执行时间超过1秒的查询记录),或通过Profiler查看单请求的数据库查询次数、单条查询耗时
- 缓存状态:
- APCu、OPcache的实际生效状态(可通过
phpinfo()或bin/console cache:status输出结果) - API Platform缓存配置情况(是否启用Doctrine缓存、HTTP缓存)
- APCu、OPcache的实际生效状态(可通过
- 服务器资源:请求执行期间的CPU、内存、磁盘IO使用率数据(可通过
top/htop或监控工具获取) - 依赖包列表:执行
composer show输出的完整依赖清单,重点标注Doctrine MongoDB ODM、LexikJWTAuthenticationBundle等核心包版本 - 代码片段:慢请求对应实体类的定义(含关联关系、序列化组配置),以及自定义的数据处理器、事件订阅者、过滤器等相关代码
内容的提问来源于stack exchange,提问作者Егор Рудаков
相关产品推荐
相关产品推荐

