duanfu1873 2012-11-19 17:37
浏览 59

Symfony2防火墙需要很长时间

I have a problem with Symfony2 firewall component taking ages on some requests.

I've noticed that it mainly happens during AJAX requests, and very specific ones - when I search for an entity using LIKE %..% statements in doctrine (not sure it matters, but that's what I noticed ;)).

Calling the same URL a little later (1 or 2s later) results in "normal" firewall processing time.

I am not using any external data sources for authentication, everything is stored in PostgreSQL.

Look at the following timeline:

timeline

Is there a way to debug the firewall directly?

My config looks like this:

security:
firewalls:
    admin_area:
        provider: db_users
        pattern: ^/admin
        anonymous: ~
        form_login:
          login_path: /admin/login
          check_path: /admin/login-check
        logout: 
          path: /admin/logout
          target: /admin
        switch_user: { role: ROLE_SUPERADMIN, parameter: _become_user }

    secured_area:
        pattern:    ~
        anonymous: ~
        http_basic:
            realm: "Secured Demo Area"

access_control:
    - { path: ^/admin/clip-manager/clip/encode/*, roles: IS_AUTHENTICATED_ANONYMOUSLY, ip: 127.0.0.1 }
    - { path: ^/admin/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/admin/login-check, roles: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/admin, roles: [ROLE_ADMIN_LOGIN, ADMIN_AREA] }

providers:
    db_users:
        entity: { class: Webility\Bundle\AppUserBundle\Entity\User, property: username }

encoders:
    Webility\Bundle\AppUserBundle\Entity\User:
        algorithm:          sha256
        iterations:         3
        encode_as_base64:   false

acl:
    connection: default

I am using Symfony\SecurityBundle and JMSSecurityExtraBundle.

  • 写回答

3条回答 默认 最新

  • dongzaijiao4863 2012-11-19 21:13
    关注

    It's rather unusual behaviour (unless you're doing something, well... unusual ;).

    Try using one of the PHP profilers to see what's going on. I can recommend XHProf with XHProf GUI. It's easy to set up and use.

    I'm just guessing, but the problem might be related to the database query you mentioned. Check if fields used in a query have appropriate indexes set.

    Edit: I accidentally stumbled on this article linked from the Symfony blog: http://12wiki.blogspot.com.es/2012/11/why-does-symfony-2-firewall-take-so.html

    It seems to be a DNS issue.

    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么