douzhuo2722 2015-10-19 00:36
浏览 80

Laravel的表现

I was going to port a custom webstore application to Laravel, so that it's new, shiny and is a pleasure to support. After spending a couple of hours on setting up the framework and starting to port the main layout, I decided to test how it performs. I have installed a copy of my original app and the ported part to laravel, where I set up a Section model with a translation from dimsav/laravel-translatable and output the main navigation with Section::all() of about 30 sections.

I was shocked when I saw the result of simple observation of the Netwrok tab in Firebug:

For my laravel setup it takes roughly 360ms to render just the above. I imagine how much the response time will be when the whole page would be ported...

For the original app it takes ~30ms to serve the whole homepage with the same navigation, popular products, submenus, footer navigation, checking cart contents etc.

Both on the same virtual server and even using the same database, no caching in either.

I profiled the code to discover any issues, but all I found is that

  • 6.4% is spent on autoloading (32ms - more than the whole requesto for the other version),
  • 12.5%/63ms - service registerting
  • 11.1%/56ms - configuration loadig
  • 44.5% on endless Pipline calls. about the time seems to be spent on endless Pipeline calls.

Just to confirm, an empty laravel app responds in about 17ms.

Am I missing somethign here? I imagined there would be some performance degrade when moving to the framework, but (assuming the reponse time will increase for the complete setup, so I would expect ~20x) 20x seems crazy. Are these time normal for laravel and is there any big win from using caching (Redis for instance) or any other optimization techinques? I wonder if there actually are any except for caching?

  • 写回答

1条回答 默认 最新

  • dongqi6486 2016-02-11 14:27
    关注

    On a $5 VPS instance from Digital Ocean with deployed apps I see response times:

    512MBMemory 1 Core Processor 20GBSSD Disk

    Lumen 60-120 ms Laravel 100-300 ms

    These particular apps do not caching. The 100-150 ms response time seems to be the base response time with laravel for a view that has already been compiled. Obviously having slow queries will increase that.

    Adding redis or memcached will dramatically degrease your response time compared to going to the db in most cases getting pretty close to the base response time of laravel.

    You should make sure to set APP_DEBUG to false in your .env file:

    # /.env
    APP_ENV=production
    APP_DEBUG=false
    

    Run php artisan optimize

    评论

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看