Prkom
V2EX  ›  问与答

[求助] 部署到服务器上的项目,每隔一段时间请求耗时会变长

  •  
  •   Prkom · Apr 28, 2021 · 1926 views
    This topic created in 2024 days ago, the information mentioned may be changed or developed.

    有用户反映页面时快时慢,拿接口测试之后发现,每隔一段时间没人访问请求耗时会变长。

    比如正常 500ms 的请求,第一次访问会耗时 3s 左右,接下来访问就恢复正常。查看 TP 日志时第一次的访问时间并没有变长,初步推测时服务器的原因,但不知从哪里入手,有盆友知道什么原因吗,谢过了~

    下面是项目相关的信息

    • 项目框架:TP 5.1.39
    • PHP 版本:7.3.27
    • Apache 版本:2.4.46
    9 replies  •  2021-04-29 08:44:16 +08:00
    renmu123
    renmu123
    Apr 28, 2021 via Android
    1
    盲猜缓存过期了
    106npo
    106npo
    Apr 28, 2021❤️1
    2
    给所有步骤打时间
    肯定有一个步骤是做了缓存的
    xenme
    xenme
    Apr 28, 2021 via iPhone
    3
    后端链接建立时间?超时关闭后建立新链接耗时太长?
    Prkom
    Prkom
    OP
    Apr 28, 2021
    4
    @xmumiffy 可以大概说下怎么操作么,代码里面日志把步骤覆盖了,没发现时间变长
    Prkom
    Prkom
    OP
    Apr 28, 2021
    5
    @xenme 有可能,我去 Google 下这方面的知识,感谢
    markgor
    markgor
    Apr 28, 2021
    6
    TP 我记得是有做缓存的;
    php opcache 也是有做缓存的;
    oott123
    oott123
    Apr 28, 2021
    7
    看你 PHP 和 Apache 是怎么配置的,我觉得很大可能是因为 Apache 在闲置之后把 PHP 的进程都杀了,首次访问需要冷启动一个进程,所以慢
    PerFectTime
    PerFectTime
    Apr 28, 2021
    8
    单机部署还是有做负载均衡,会不会是连接关闭了需要重新发起链接
    Prkom
    Prkom
    OP
    Apr 29, 2021
    9
    @PerFectTime 单机部署的
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   3152 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 04:09 · PVG 12:09 · LAX 20:09 · JFK 23:09
    ♥ Do have faith in what you're doing.