dongqiangse6623 2017-11-10 06:27
浏览 86
已采纳

如何在PHP中改善MySQL连接时间?

As testing performances on APIs, I found that 30% of response time for APIs are spent on connecting to MySQL. (Min. 500ms - Max. 600ms)

I assumed that it was because of MySQL settings, so I changed various settings to improve the connection time, but without luck.

I did not use any framework to test it. I wanted to compare with other languages, so I tested Python. Its result was around 50ms which is a lot better than 500-600ms of PHP.

What would be the reasons for such delay on PHP, but not on Python?

Here is the environment under which I tested:

  • php version : 7.1.9-1+0~20170902060604.8+jessie~1.gbpebe5d6
  • python version : 3.6.2
  • platform : Linux(Ubuntu)
  • mysql version : 5.7.2
  • 写回答

1条回答 默认 最新

  • douzhi1879 2017-11-10 06:37
    关注

    Depending upon your use case, you may be able to dramatically increase your response time by using persistent connections.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 求快手直播间榜单匿名采集ID用户名简单能学会的
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历