stocksph's avatar

Laravel Speed

Hi, Newbie here. I just installed a default laravel but I'm quite concerned with the speed. The speed is ranging from 300ms-700ms My other sites that dont use laravel run at 20s-100ms only is that acceptable to run default laravel installation(without any added codes) at 300-700ms? pls enlighten me. any help is greatly appreciated.

0 likes
23 replies
willvincent's avatar

There are a ton of variables here that you aren't providing any information about. What does the environment look like? Any caching in place? Running inside a virtual machine, or natively? If it's in a virtual machine, how are you mounting the shared files? etc.

Laravel is plenty fast..

I have a dev site, running inside a VM, most pages are ~56ms, with 2 queries each, the heaviest page is responding in ~320ms with 8 queries running, most of which are somewhat complex, and lots of manual calculation/processing happening within PHP after the queries run to parse the queried data.

1 like
kobear's avatar

I have a site on my dev server, which is a vm, that uses 6 queries and 3 blade templates that on average takes 150ms. And this is without doing any caching.

1 like
stocksph's avatar

its running on digitalocean server.

its running on

ubuntu 14.04 1GB RAM 1 core processor 30GB SSD 2TB Transfer Apache 2.2 Mysql 5.6 PHP 5.6.23

site: http://www.stocksph.com/tournaments/public/

also implemented artisan optimize its caching on "file" as I just installed the default installation as of now the settings are all in default configuration.

is the 300-700ms acceptable on default installation?

i also tried another installation and the caching was set to "apc" and the speed is around 250-400ms.

jlrdw's avatar

I am totally confused on speed please someone straighten me out, all these people talking about milliseconds, I surf the web all the time I don't see any site loading that fast even on high speed internet they take a good two to four seconds to load so what is this deal with this millisecond stuff? Most take longer than this to load even pagination right here on this very forum like going from page 1 to page 2 so what is the deal.

1 like
kobear's avatar

@jlrdw the issue here is the cumulative effect. @stocksph is concerned that if a single user requesting a page on his development server is taking X amount of time, then what happens when more users are on the system. The expectation is that performance will degrade with more users if the single user experience is in the 300-700ms range.

kobear's avatar

@stocksph how are you determining the speed of 300-700ms? Are you using timings on your browser, or are you using timings generated by the server?

stocksph's avatar

@kobear - that is very true.

any tips/tutorials on how to speed up my default installed laravel? coz 300-700ms is quite unacceptable.

my aim is to run default laravel at less than 50ms using my current environment

ubuntu 14.04 1GB RAM 1 core processor 30GB SSD 2TB Transfer Apache 2.2 Mysql 5.6 PHP 5.6.23

jlrdw's avatar

It shouldn't multiply like that it will finally flat line.

kobear's avatar

@jlrdw it is not multiplying by a constant factor, but as you load users on the platform, it will have a cumulative effect. And web servers do have a limit on the number of concurrent pages being served, concurrent sessions, etc. In those situations, application tuning can gain you much, and then you look to using reverse proxies (aka: load balancers) to have multiple web servers share the load.

stocksph's avatar

@kobear im using the timings on my chrome browser developer tools. just wondering how to monitor it on server as well?

im a complete newbie.

any help is highly appreciated.

kobear's avatar

@stocksph again - how are you measuring your page timings? If you are doing it via browser timings, that will always show you an inflated figure because then you are including network transfer time and render time on the client.

It is better to use something like Debugbar ( https://github.com/barryvdh/laravel-debugbar ). That shows your server side timings with each request

1 like
jekinney's avatar

Clockwork chrome and php plugin works well.

But as was stated your not measuring server time. Your measuring the trip and render time which verys on every page refresh. Each connection needs to find the server and be routed to the server. Which can be very inefficient plus your ISPs network etc etc.

Due a trace route to your server ip. That will give you a general idea how long it takes for the request just to hit your server and time for return. Obviously that time can be subtracted from your dev tools time. But it will also show that connections are not the quicker route distance wise. I have had routes go from west coast to east coast back to the Midwest in the USA. Holy inefficient but nothing you can do about it.

1 like
kobear's avatar

@stocksph Yeah, dont use Chrome browser dev tools to measure laravel speed. debugbar will give you real laravel timings, without network latency timings masking performance.

Some next steps if you want to make sure you are getting the best performance:

  • Enable gzip compression on your webserver
  • Switch to a memcached or redis caching system for your models
  • Look at your models and determine if you need to create indexes in the database based upon the queries you are using.
1 like
stocksph's avatar

thanks for providing this. i really appreciate it.

btw just also wondering if the 300-700ms (default installation) in my "browser timings" acceptable? my internet speed is 80MBPS

kobear's avatar

@stocksph 300-700ms browser timing is relatively ok. Has room for improvement though.

jekinney's avatar

@kobear good info, and add too:

Utilize timing headers for your CSS, images and scripts so the browser doesn't check for changes every page load. Keep in mind each browser can only handle X amount of calls at the same time. So a page with 2 CSS files, 20 images and 2 scripts will take at least two separate calls if not three. (Chrome I believe is ten at once).

1 like
stocksph's avatar

@kobear - i mean just the default installation. is the 300-700ms really ok? if it is okay, i would proceed with the

http compression (gzip) page caching image caching js vaching css caching db caching

headers expires etc

my site traffic is around 1k-3k users and around 20k pageviews per day.

what do you think?

willvincent's avatar

@stocksph without an optimized server, yes it's fine. I think a 1GB droplet is undersized for your traffic load, unless you're heavily caching rendered pages.

The slowness here is almost certainly the environment, not the framework.

ShaneTurner's avatar

I've had the odd 'rotten' droplet with DO. High latency and slow load times. First time this happened it took about a week of back a forth support with digital ocean support team trying to find the root of the problem. Optimized, cached, checked network etc. In the end, on a hunch, I just copied the server image to a new droplet and the problem vanished.

Just an FYI in case all else fails.

stocksph's avatar

@willvincent - as for the optimized server, can you give me a detailed tutorial to do that? I'm using digitalocean 1GB LAMP.

Any help is greatly appreciated.

willvincent's avatar

@stocksph Sorry, no. I'm not in the business of generating devops/server admin tutorials.

I will say though, nginx is generally more performant than apache. php 7 is considerably faster than php 5.x, mariadb is more performant than mysql (and better on memory than the latest mysql).. and for a heavily trafficked site, something like varnish is a must.

Why website which currently runs on Drupal, which is kind of a resource pig, loads almost instantly thanks to the cache layers (varnish, apc, etc), granted it's also on a much more robust server than your 1GB droplet, but still.. slowness you're seeing isn't the framework. It's response time of your server, network latency between you and digital ocean, etc.

Please or to participate in this conversation.