5

I did a lot of search and no solution worked for me.

Firstly, I have two projects on the same server, one using CodeIgniter and the other using Laravel.

The one which uses Laravel occasionally loads very slow
This image shows empty page written with Laravel
enter image description here

And this image shows that user waits for about 33 sec. enter image description here Sometimes, this time comes from Receiving

I had a quick look for some websites that run Laravel. I noticed that this issue exists there too, you can try October CMS .

Finally this is what I did:

  • Set debug to false
  • Run artisan optimize --force
  • Set database to 127.0.0.1 not localhost

Any ideas? and please note this happens occasionally and randomly

Community
  • 1
  • 1
Samy Massoud
  • 4,295
  • 2
  • 35
  • 48
  • 2
    Is it the same request that takes occasionally too much time or different one each time? Did you try using xdebug or similar to check what is happening server side? – piotrekkr May 15 '14 at 09:03
  • request may be different , but on the same server codeigniter run very smooth with no issues like that one , and no i didn't use xdebug . – Samy Massoud May 15 '14 at 09:05
  • 4
    I presume that codeigniter do different thing than laravel app? Why don't you try making some batch requests to server and at same time monitor server load and statistics for example: `for i in {1..20}; do curl -s -w '\nURL: %{url_effective}\tTOTAL_TIME: %{time_total}' -o /dev/null -q http://google.com | tee -a log_url ; done` maybe it will give you some hints – piotrekkr May 15 '14 at 09:42
  • @piotrekkr what is batch request ? do you have a good tutorial for that? and for my question it's just white page do nothing at all !!! – Samy Massoud May 15 '14 at 09:45
  • Batch request is many request one after another :) `for i in {1..20} ...` will make 20 requests using curl. You can get curl statistics like in here http://archive09.linux.com/feature/57715 in `Get server metrics` section – piotrekkr May 15 '14 at 10:10
  • Is OPCache enabled ? Disable it if it is and see if that helps. –  May 17 '14 at 12:22
  • So, you are certain there is nothing in your own code that is slow? A simple route with `return "Hello, World!";` is occasionally slow aswell? – AntonNiklasson Jul 10 '14 at 09:44
  • 1
    I'm not sure if you have already figured this out yet but to me it seems like the problem exists server side. I'd recommend that you use an Application Performance Management (APM) solution to quickly narrow this down. NewRelic is free and easy to install (although I haven't used it) which will point you exactly to the line of code or any setting that taking longer to respond. Good luck. – na-98 Jul 23 '14 at 01:38
  • 1
    also check out debugbar. gives lots of debugging info https://github.com/barryvdh/laravel-debugbar – ryanwinchester Jul 26 '14 at 22:49
  • I will second using XDebug to profile your application. The built-in profiling tools ( http://www.xdebug.org/docs/profiler ) should help you identify the bottleneck – Seb Barre Aug 06 '14 at 12:08
  • Does the slowness occur after rebooting? I think the slowness will occur because the linux filesystem cache will be cleared. Try to run `echo 3 > /proc/sys/vm/drop_caches` and see if the slowness occurs. – ArjanSchouten Aug 18 '14 at 12:25
  • 1
    This sounds like a server application issue. What is in front of your PHP application? (Apache, Nginx, etc.) Would you be willing to post your configuration file for this? I have never seen PHP take this long, but I have seen server applications with incorrect try structures take this long. – BayssMekanique Aug 22 '14 at 16:38
  • @BayssMekanique +1 for your suggestion , Yes indeed i figured that server and Stack are factors of this , i might post full answer here – Samy Massoud Aug 24 '14 at 08:27

1 Answers1

1

This is not an issue with Laravel, it is most likely an issue with how your server is configured. Most likely it could boil down to how you have Apache/Nginx configured, where and how you are loading your static assets and other variables.

By the sounds of it, you are using a stock version of Laravel and stock version of PHP, the only difference between the two being which PHP features one another supports and the structure of the applications themselves. In my personal benchmarks Laravel is undeniably faster than Codeigniter due to lazy loading. Have you tried running the same tests on a different server or even locally on your own machine?

Dwayne Charrington
  • 6,524
  • 7
  • 41
  • 63
  • Some how Laravel consume more memory than CodeIgniter , so on Amazon Ec2 instance where it's ram about 600 MB and when i use Apache Laravel take more time to load , but after tweaking server by removing Apache and using Nginx every thing went Ok :) – Samy Massoud Sep 17 '14 at 07:16
  • 2
    I am glad you got it all sorted. I love Nginx, it's like driving a sports car after driving a family sedan (Apache). Also worth mentioning, you should try out Phalcon. It's an in-memory PHP framework built as extension and it is incredibly memory efficient and the fastest PHP framework out there. – Dwayne Charrington Sep 17 '14 at 22:41
  • I'm also facing the same problem. Even in my localhost itself is taking an average of 1300ms to get the response. Please advice. Changing the environment and disabling the debug can help us? – JTheDev Jul 01 '16 at 04:20