How to debug slow running stock install of Laravel 4 on Cpanel - php

I've installed an out-of-the-box L4 project on both my local workstation and on my production Cpanel server. It has no database connectivity and I'm just hitting the stock home page with Laravel logo. My local install responds in 80ms or less, however the production server that is far more powerful takes between 2.5 - 8 seconds to respond. It's awful slow.
Debug is False. Every once in a while I'll get a fast response, but I can't make sense of it's randomness, The server is a powerhouse with 8 cores and 16 GB of RAM. It only hosts one other website. I can pull up the robots.txt or phpinfo file instantly, so it's not just a server issue. Here's the staging site that I'm working on: http://staging.dirtondirt.com/
How can I figure out or debug where the slowdown is?

You can use the popular Laravel DebugBar -
https://github.com/barryvdh/laravel-debugbar/tree/1.8
In this, it gives you a 'timeline' of aspects of your application, so you can see what is causing the slow load times.
If that fails - another option is Blackfire.io - which is a new service - I havent tried it yet, but they support Laravel.

Related

AWS Lightsail instance downs from wordpress requests

I've setup the low cost AWS lightsail server for multiple wordpress sites following the article-
https://www.wpmentor.com/wordpress-with-nginx-lightsail/
Server runs good for normal requests. But after a while, I needed to install W3 Total Cache and clear all the cache after moving sites from localhost/github. But when I'm clearing all cache, the site goes on loading and after a while it returns 504 Gateway Timeout. Also the lightsail instance goes down and can't even connect with ssh, it's need to stopped and started again (reboot don't works either). Lightsail matrix shows the CPU burst over 80/100 %.
I'm very confused about the whole situation. Please somebody help me!
The $3.50 plan gives you a t2.micro, which only has 512MB of memory and 1 burstable CPU.
I'd be surprised if there's enough RAM on that system to be able to support a cache. It's probably paging heavily to disk, which would directly impact performance.
You'll probably need to move to a larger instance type.
See: Creating a larger instance, block storage disk, or database from a snapshot in Amazon Lightsail | Lightsail Documentation

GAE with Laravel / Lumen extremely slow

I have a server hosted on DigitalOcean responding within 70-300ms window depending on the request. The same code when hosted on GAE external or local server response time goes up 3 times even when I put dd('test') in index.php file. It's clear GAE PHP interpreter is extremely slow. Did anyone experience this problem and fixed it?
What I found out is it takes longer for GAE to boot laravel or even lumen than it takes my 5$ DigitalOcean server to respond! It's ridiculously slow.

Remote Redis connection slow

I am experimenting with using Redis for a Drupal website, hosted on Ubuntu 14.04.
I have installed the redis drupal module and am using the Predis library. I have also installed the 'redis-server' Ubuntu package and left the default configuration.
Configuring the Drupal site to use Redis for its cache backend works fine and the pages are lightning fast.
The problem arrives when I tried to spark up an m3.medium AWS instance and hosting the redis server there. The reason behind this is so that we can use one redis server and connect to it from multiple servers (live website hosted on multiple instances behind a load balancer, so each instance should connect to the same redis server).
I have set up the redis server on the instance, modified the redis.conf file to bind the correct IP address so it can be accessed from the outside, opened up the 6379 port, then tried connecting to it from my local computer
redis-cli -h IP
It worked fine so I decided to flip my local site's configuration to point to the new redis server.
The moment I did that the site became painfully slow, and at first I thought it might not even load at all. After almost a minute it finally loaded the home page. Clicking around the site was almost as slow, but the time reduced to maybe 10-15 seconds. That it still unacceptable and doesn't even compare to the lightning fast page load when using the redis server.
My question is: is there some specific configuration I need to do to make the remote connection faster? Is there something preventing it from performing well? some bottleneck somewhere?
Let me know if you want me to add the drupal settings.php configuration, although I am using a pretty standard config.
Although I ran the same configuration for a php application as you are trying, I had no issues hosting redis on either a small or medium instance and handling large amounts of traffic. There must be a config issue somewhere. Another option to debug it would be to try switching to Elasticcache (AWS' redis offering) it requires that all clients be within the same region, but could make finding your problem very easy.

Apache deflate and progressive HTTP response

I work on an e-commerce website and we have important performances difference between our production server and our test server.
Both are VM running on Windows Server 2008 R2 64bits with WampServer 2.5 (Apache 2.4.9 / PHP 5.5.12).
(Note : I know that WampServer is not for production uses, but at this time it's still the best solution for us as we highly depend on Windows environment for our databases and other stuff. We tried to optimize Apache & PHP configuration for production, and we replicated that conf on our test server, so we have the same environment on both machines.)
Everything was running okay from there, until today. We were attempting to improve Apache files compression configuration (disabling it on images, enabling on html files, etc) when we noticed a major difference between the two servers.
On the same page (for test needs : an huge products list with a lot of content and images to display), same request, same user, same browser :
The production server seems to "prepare" the whole document before sending it. During several seconds I've to wait and watch a blank browser, then all shows up instantly. In Chrome Dev Tools, Waiting time is around 7 sec and Receiving time around 50 msec.
The test server seems to do just the opposite : no blank page during seconds, the header is displaying very quickly and the rest of the content comes step by step while I can already browse the page. Waiting time is around 200 msec and Receiving time around 11 sec.
On my own development machine, I can observe both situations when I toggle Apache's configuration for mod_deflate.
So after several attempts, we just disabled the mod_deflate on the production server, and then on the test server. Both have the exact same configuration, and still there is this big difference.
I also looked on php.ini files, thinking about cache issues or something like that, but same deal here : both configuration files are matching but the two servers are still working differently.
We spent hours searching answers on the web, but nothing seems to work...
Please, can somebody help us on that ?

How to debug performance issues in AWS Elastic Beanstalk

For the last couple of days, my web application has been very slow, sometimes returning a 503 error instead.
Locally the app runs fine.
With so many moving parts involved, how do I know where to look? Is it my code (and if yes how do I find what)? It is Amazon? Is it the database? Did I outgrow my instance?
I am using Amazon Elastic Beanstalk (1 small instance), with MySQL RDS (1 micro instance), and the code is in PHP. The site has relatively low traffic (about 1500 page views this past week).
You need to use xdebug to do profiling: http://www.xdebug.org/docs/profiler Then you can load that profile with a program that views cachegrind files (such as http://sourceforge.net/projects/wincachegrind/) to find the slow spots. You could also turn on the mysql slow query log and see if there are any trouble spots there. (In my.cnf: log-slow-queries = [path to the log file], then restart mysql)

Categories