I have optimized performance by this documentation page:
http://symfony.com/doc/current/performance.html#optimizing-all-the-files-used-by-symfony
except parts "Caching the Autoloader with APC" and Use Bootstrap FilesĀ¶
because when calling line
include_once __DIR__.'/../app/bootstrap.php.cache';
I got an error.
But page still loads at best about 2.5 seconds even if application does nothing, just outputs small hardcoded text.
I am running php built in server like this:
php -S 0.0.0.0:8000
and version is 5.6
I know with php 7 it should be faster, but before php 7 people still used to code with php 5.6. Were they really coding and waiting 2.5 seconds for each page reload? And if application does some heavier work it then would take even more.
My machine is running on windows 7, 8 GB ram, Intel B960 processor.
Can I do something to increase load time more? I think its a waste of time to wait 2.5 seconds for each small fix because it adds up over time. I want the app to be lightning fast.
"Normal Symfony Loadtime" clearly depends on your machine. I've also noticed some high loading times in dev and localhost, whereas in dev on a server (a mid level one) I'm under 300ms per page (and even quite big ones...)
The only fix for me was to develop on a server and abandon localhost.
Related
I am using out of the box Laravel 9 / php 8.1 combo and loading initial page for 190ms sounds horrible. Last project I built used laravel7 and the response times in development including database queries - talking complex ones were less than 20ms
Currently I am trying to set it up, so the tests were simply loading the default route or just a route returning a string.
I tested several instances
Custom docker container I've built (amazonlinux, php81, php81-fpm / nginx ) on an old server
Local Windows 10 instance / php81 / artisan serve
Pre-built container by bitnami
All of them showed responses ranging from 80ms to 2200ms
My custom container because of the optimizations showed responses of 60ms - 80ms, but on the 3rd-4th refresh it pulled a 450-900ms response time
On Windows 10 instance there was stable response, but horribly slow ~85-130ms
Pre-built container was also stable on around 190ms
You can understand the horror as those are simply empty frameworks deployed.
My test case where a database from another container was pulled to select 1-100 records didn't change the response times. Database was pulled in less than 10ms.
For comparisson, because I started reviewing php-fpm configuration (still out of the box on all test cases) I ran some benchmarks if this is the bottleneck, but it was performing flawless. Ops/sec were as described on normal php8.1 benchmarks
Strange thing I've noticed was within Xdebug on my custom container, there were 2300 more records below this.
Did you try to change your WSL config or install other distro like ubuntu etc? I had a similar issue on windows and NTFS issue. I changed my distro to ubuntu LTS and become faster like a normal website.
So for now I've concluded that the main issue is mainly with Docker and the fact that laravel was sitting in an folder exposed to the machine.
The responses are delayed because the performance of those folders is literally slowed down 60 times.
After further testing this is what it all comes down to. I am upgrading the hardware from a server HDD to m.2 to ignore partially this slowdown.
My tests showed 1.83 mb/s transfer rate for the shared folder on the server compared to 110 mb/s on the dedicated server.
I created Yii2 basic app https://www.yiiframework.com/doc/guide/2.0/en/start-installation but the index.php waiting time (TTFB) always is around 2s, no less, download time is around 43ms and all the other resources of the default app (CSS, JS) are donwloaded withing 10ms (all as observed from Google developer tools), that is fine. I am running everything on my development machine Windows 10 4GHz, 16GB RAM, low resrouce consumption.
I am adding the xDebug profiling results of index.php call: Results ordered by Incl. and Results ordered by Self.
It can be seen that there is no single slow PHP function, though it is shown that 50% of the self-time is consumed by php::fclose my experiments show that commenting out those two lines only marginally improves the situation. So - it is quite hard to rely on xDebug profiling.
I also experimented with commenting out or changing debug settings but such activities give no improvements as well.
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');
2 seconds is very big response time for the application without any functionality and running on the local machine with plenty of resources. We have experience that quite complex Yii applications respond in less than 0.5s and that is fine, but 2 seconds is unacceptable time.
I am using XAMP, PHP 7+, Yii 2.0.14, there is issue filed https://github.com/yiisoft/yii2/issues/15776 that 2.0.14 specifically may be slower but issue is not confirmed, as I understand.
I downgraded the same project to Yii 2.0.5 and tried it under XAMPP with PHP 5.6.23 and the performance is excellent. All the index.php request is completed under 100ms (in Yii 2.0.14 / PHP 7+ it took more than 2s).
Another finding - Yii 2.0.13 basic app works fast under XAMPP PHP 5.6, but this same app return page after more than 2s under XAMPP PHP 7.2. So, possibly the performance problems are not due to Yii2.
How to proceed? What other profiling to do? What other settings to change?
I was investigating the same issue and in my case it was related to xDebug.
I'm using Windows 10 for developing, php 7.1.17 and Yii 2.0.15.1 and tested with the yii basic application.
I also tried yii 2.0.14 / 2.0.13 / 2.0.6 / 2.0.5 and there was always a TTFB of +1100ms.
After disabling xDebug in the php.ini the TTFB dropped to 250ms, which is excellent and feels perfectly fine.
Maybe this issue is related to xDebug and happens only while developing, on the production server it should be fine!
The issue
I recently upgraded PHP on my server from PHP 5.6 to PHP 7.0, for some reason this has caused an incredibly long TTFB (compared to before).
Quick overview of how I set up my website
My website uses a combination of client and server side optimizations to make my run at an insane speed (average of 250ms for an initial full page load), causing as little overhead for the users as possible.
However, ever since I upgraded to PHP 7.0, the time to first byte increased from around 50ms up to anywhere from 700ms to 2000ms (which feels like an eternity compared to the load times before this).
The question
I was wondering if there are known performance issues with PHP 7.0 compared to PHP 5.6, and if so how I could fix them. Thank you for your time
I rent Windows 2008 64 R2 on a shared hosting environment with the following specs:
Intel XEON E5520 # 2.27GHZ
2 GB RAM
IIS 7.5
PHP v5.4
MySQL 5.5.27
FastCGI
Normally, I develop for .NET, and my websites are working great with fast rendering times.
However, I have a couple of Wordpress sites as well, and they are rather slow compared to the .NET websites. Today, I decided to investigate this. I just installed a fresh WordPress 3.8 copy using WPI (Web Platform Installer).
The website takes about 1.1 seconds to render (so it takes 1.1 seconds before any response is returned from my web server), which is, in my opinion, really slow.
I didn't install PHP/MySQL on the server myself, but I think that the best well known practices are in place, at least FastCGI is installed.
But still, I believe that Wordpress should be performing much better, even on a WIMP environment.
So, my questions are:
Should I expect more performance with this setup on the given environment (no additional optimizations such as caching), or is 1.1 seconds of rendering time normal?
And if so, any ideas on what's going on?
Btw, I know that I can speedup Wordpress somewhat by using plugins like W3TC.
Today, I finally was able to fix my slow loading problem; until now, my Wordpress sites where still loading slowly.
By chance, I stumbled upon this article:
http://www.customfitonline.com/news/2013/6/20/solve-wordpress-on-windows-server-problems/
I was like, let's try that "Slow Page Loading" tip, change localhost to 127.0.0.1 in wp_config.php:
define('DB_HOST', 'localhost');
To
define('DB_HOST', '127.0.0.1');
Sure enough, this setting makes a HUGE difference in page loading!
There is a PHP application right now on a Linux box running under Apache with MySQL. Since we are a windows shop, management wants to get rid of the Linux box and move everything over to windows. Is there a performance difference between the two platforms? Or, is there any significant difference at all, in terms of performance or management?
Microsoft had a team help out optimising PHP for Windows, which work is part of PHP 5.3. Some figures I've seen places the performance close to PHP + Apache on a unix system. Before 5.3 (Which means currently, since 5.3 isn't out yet), performance is bad on Windows. I think there are some patches and tricks you can pull to improve it, but it's going to cost you a bit of performance. That may or may not be a problem; People have a tendency to overestimate performance.
Note that there are other reasons to use unix than just performance. Code may not be portable and even though the core php runs fairly ok, you can well get into trouble with php-extensions and third party libraries. No matter how you look at it, Windows is a second-rate system for running php on.
If your application isn't huge or get hit a couple thousand times per second, there's no difference between the two.
LAMP == WAMP in php small projects. Just install something like XAMPP if you want your environment to be as close as possible to your existing one but in Windows.
Good luck with your project!
You should consider the MS WebPI (download at www.microsoft.com/web ) which would install the entire stack for you to run PHP in IIS7 environment.
the performance is comparable for most apps.
I've just done this for the same reason. Mgt wanted to get rid of the Linux box. I was able to completely move my php application and MySQL database. It took longer for me to configure PHP for IIS than it did for me to move the existing content over.
I have found though that the IIS server is a fair bit slower when it comes to loading pages and images. Where in Linux it appeared instantaneous, in IIS it takes a half second for the page to load and another second for images.