I have been working on a new project for work and have been running into a weird issue where my application takes a long time to return a response both in dev and prod. However sometimes it returns a response really fast. I read a few posts on here about possible reasons why but none of them have solved my issues.
At first I thought it was because I had a few sub requests made so I removed those but still had the same issues.
My average request is only between 20-30MB in DEV. I am trying to use the profiler to help me figure out where this may be coming from, however every request it shows the longest part of the request to be a different area. For example, in one request the longest section was the controller, in another request to the same page it was the template listener, on another it was the security/firewall listener.
For example, a fast request on my homepage takes about 116ms. I wait a min, refresh and it takes 9467ms, or even I have seen it take 30,000+ms.
While I can live with a little slowness in dev mode, prod is doing the same things. Sometimes fast, sometimes slow. APC cache is enabled. Generally my doctrine queries only take 4-20ms to complete depending on the page.
I was running PHP 5.3 but decided to upgrade to 5.4 to see if that helped, still the same issues. I am using the latest stable build of nginx. PHP in FPM. Server is running other websites with no issues - both magento and symfony 1.4 web applications with no issues like this.
Server is a quad dual-core with 32GB of ram so I have plenty of resources. Watching the processes as I make requests I do not see abnormal cpu or memory loads.
I have yet to try to run the application on a different machine - but I do not see why all my other applications would be working fine and this one is the only one experiencing slowness like this. I will probably test that tonight but I wanted to see if maybe anyone has experienced an issue like this before.
Here are some snapshots from my profiler when the request takes a long time:
Here are two when the request was fast as expected
This is my composer.json
{
"name": "spliced/commerce",
"minimum-stability": "dev",
"description": "",
"autoload": {
"psr-0": { "": "src/" }
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.2.*",
"doctrine/orm": "2.4.*",
"doctrine/doctrine-bundle": "1.2.*",
"twig/extensions": "1.0.*@dev",
"symfony/swiftmailer-bundle": "2.2.*",
"symfony/monolog-bundle": "2.2.*",
"sensio/distribution-bundle": "2.2.*",
"sensio/framework-extra-bundle": "2.2.*",
"sensio/generator-bundle": "2.2.*",
"jms/security-extra-bundle": "1.4.*",
"jms/di-extra-bundle": "1.3.*",
"symfony/assetic-bundle": "2.1.*",
"kriswallsmith/assetic": "1.1.*@dev",
"vbardales/multiple-app-kernel-bundle": "dev-master",
"avalanche123/imagine-bundle": "v2.1",
"knplabs/knp-menu-bundle" : "dev-master",
"knplabs/knp-paginator-bundle": "dev-master",
"knplabs/knp-components": "*",
"symfony-cmf/routing-extra-bundle": "*",
"stof/doctrine-extensions-bundle" : "dev-master",
"facebook/php-sdk": "3.2.*",
"kertz/twitteroauth" : "*",
"adoy/oauth2" : "dev-master",
"guzzle/guzzle" : "dev-master",
"knplabs/knp-snappy-bundle": "dev-master",
"symfony-cmf/routing-extra-bundle" : "*",
"floriansemm/solr-bundle": "dev-master"
},
"require-dev": {
"zendframework/zendframework": "dev-master",
"elao/web-profiler-extra-bundle" : "dev-master"
},
"repositories": {
"goutte": {
"type": "package",
"package": {
"name": "fabpot/goutte",
"version": "dev-master",
"source": {
"type": "git",
"url": "git://github.com/fabpot/Goutte.git",
"reference": "master"
},
"autoload": {
"psr-0": {
"Goutte": "src/"
}
}
}
}
},
"scripts": {
"post-install-cmd": [
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
],
"post-update-cmd": [
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
]
},
"config": {
"bin-dir": "bin"
},
"extra": {
"symfony-app-dir": "commons",
"symfony-web-dir": "web",
"branch-alias": {
"dev-master": "2.2-dev"
}
}
}
I refer you to the answer in another (same) question:
Problems with symfony performance
I guess you should set in PHP.ini those two parameters on much higher values than default ones, i.e.
realpath_cache_size = 4096k
realpath_cache_ttl = 7200
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With