Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2 loading time and performance

I am working on a not so big project (3 bundles I created and 6 I downloaded / 5 Entities) and I have placed this code on my home controller :

class HomeController extends Controller
{
    public function indexAction()
    {
        $time = microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"];
        echo $time; 
        die();

        //...

It's giving me under 100ms on the localhost (with APC enabled) which is fine.

The real problem is the behavior on the online server (using prod env and APC not installed) : If I don't use the website for like 10 minutes, the first time it is really slow to load (2 to 4 seconds) and then if I stay on the website, if I refresh the page, it is way faster (from 500ms to 1s).

Is that normal ? Is there something wrong with my online server or my symfony2 project ?

like image 959
httpete Avatar asked Mar 09 '13 20:03

httpete


2 Answers

You should definetly setup APC to decrease the loading time. Here's a note on that:

Performance

(2015 edit: link updated)

like image 100
apoq Avatar answered Nov 08 '22 07:11

apoq


Just have a look at the timeline tab of the great toolbar / profiler which Symfony provides: http://symfony.com/blog/new-in-symfony-2-2-new-stopwatch-component (not limited to 2.2)

Are you using localhost as the database_host? If so, try 127.0.0.1 instead!

Are you accessing a third party API like Facebook (FOSUserBundle)?

like image 38
hacfi Avatar answered Nov 08 '22 07:11

hacfi