12

I have set up Symfony but every page load requires 40 seconds.

If I have an empty controller it takes 8 seconds to load. If I start to make some complex queries on the database, it's worse. What can I do?

  • deactivate the profiler? (will this change a lot?)
  • activate APC on dev mode? (but will this not be a problem for changing the code)
  • put the session inside APC?
  • put Doctrine in the garbage?
  • .... ?

I don't really know where to start.

(I am using Windows 7 with Xampp server and 8gb of ram)

Jon Winstanley
  • 23,010
  • 22
  • 73
  • 116
Alexandre
  • 3,088
  • 3
  • 34
  • 53
  • 1
    The first thing you should do when dealing with slowless is profile your page. Then you'll know exactly what is taking so long and how to formulate a proper question. http://stackoverflow.com/questions/21133/simplest-way-to-profile-a-php-script – Mike B Nov 20 '13 at 14:50
  • 1
    40 secs sounds way too bad. There must be other problem(s). I don't think it's down to Symfony. – marekful Nov 20 '13 at 14:53
  • By default the kernel get 4 sec. If I start to make some db queries the controller get over 30 sec. But if I look to my queries they get less than 20ms. – Alexandre Nov 20 '13 at 15:16
  • Concerning my server, I just installer Xampp on my windows 7. When I run phpinfo(), it get less than 1 sec. – Alexandre Nov 20 '13 at 15:17
  • If I active APC for Doctrine then the controller need around 10 sec. So I would say, Symfony is not made to build complex website without to use huge amount of caching. – Alexandre Nov 20 '13 at 15:27
  • @Alexandre You're doing without understanding. Making a statement that Symfony is not ready for complex websites only makes you look inexperienced. – Mike B Nov 20 '13 at 15:41
  • @MikeB I absolutly have no experience with Symfony and Doctrine. But how Doctrine could be fast with creating such PHP object when you have complex datadase queries? So I am bit surprise, cause Doctrine is 1 of the most famous ORM, for example Zend2 also use it. – Alexandre Nov 20 '13 at 15:45
  • Your first mistake is choosing a library based on its popularity and not your requirements and experience. If you're really interested in learning why your PHP is slow then follow my advice and start profiling. If you're looking for a copy/paste answer without understanding then you should post this somewhere else. Answers that involve "enable caching" aren't answers.. they're simply covering the problem and you'll be back with a new question in no time complaining that we don't know what we're talking about. – Mike B Nov 20 '13 at 15:50
  • 2
    Start fresh. Download a new symfony project and then run some tests on the sample acmedemo app. If your development machine is capable of running Windows 7 then you should experience very little delay. No real need to fool with caches and what not on your development machine. You have something else going on. – Cerad Nov 20 '13 at 16:26
  • @MikeB I have done a bit profiling but I am starting a project and I don't want to spend hours to find out why is it so slow. As told you, most likely the issue is coming from Doctrine. When I ran the acmedemo I was already very surprise, 5 to 10 sec. When you look to the documentation, you can see the profiler displaying the same loading time (see screenshot). I used this framework as requirement from my company!! But today, I will have convince them that this kind of framework doesn't fit with our requirement. I am sorry to tell you this, but Symfony is really slow! Just google it :p – Alexandre Nov 21 '13 at 08:02
  • Take a look at this solution :) http://stackoverflow.com/a/17914570/667773 – Denes Papp Apr 27 '14 at 22:12

2 Answers2

14

A few quick suggestions:

  • install PHP 5.5.x (faster)
  • Use mod_fcgid instead of mod_php with Apache
  • Raise realpath_cache_size and realpath_cache_ttl in your php.ini
  • disable XDebug
  • ...

See this question, this question and this question.

Community
  • 1
  • 1
Nicolai Fröhlich
  • 51,330
  • 11
  • 126
  • 130
  • I will try to play a bit with the setting of my server. But I would really like to keep xdebug... Let's see ;-) – Alexandre Nov 22 '13 at 18:27
  • just create 2 vhosts with different configurations - if you're using `mod_fcgid`, `mod_fastcgi` or `php-fpm` (unix) you can set up vhosts that use 2 (or more) different `php.ini` files by passing different `PHPRC` environment variables to your php executable i.e. for different hostnames. This way you can easily have a vhost `myproject.lcl` that has xdebug disabled and a second one `myproject.dbg` for debugging :) i have some more ... one `myproject.prod` to test symfony's production settings and some more for different php versions i.e. `myproject.php54` ... – Nicolai Fröhlich Nov 22 '13 at 21:32
  • "Damn!" XDebug was one of the main reason of this issue! realpath_cache_size and realpath_cache_ttl play also a bit on the balance. I even don't need to use fcgid. The vhost is a good idea, I will create an extra one for debugging. So I stop my dev on Yii and come back on Symfony (I am kind of happy about it). Thanks – Alexandre Nov 25 '13 at 11:11
1

Something is not right on your system. 40 seconds is way too long. Even in dev mode, your pages should be showing within a second or two.

Someone else has had similar problems here: Windows 7 php + Symfony2 terribly slow

Community
  • 1
  • 1
Jon Winstanley
  • 23,010
  • 22
  • 73
  • 116