Search code examples
phpperformancecodeigniterhmvcscalable

Codeigniter HMVC effect on performance


OK, so HMVC in Codeigniter is the way to go for scalable web applications (with Kohana 3) based off many stackoverflow discussions such as HMVC patterns and MVC vs HMVC.

But, how will using an HMVC approach affect performance when used in Codeigniter? From my understanding, HMVC will "simulate a controller". Assuming a one day "large" scale project, will Codeigniter's implementation by a future problem?


Solution

  • There are two main different features that HMVC adds to CodeIgniter which often confuses people:

    1. Modular MVC
    2. Hierarchal MVC

    Modular MVC is the feature that most people want to use and is essentially just a way to have a cleaner folder structure.

    HMVC is the practise of calling controllers from other controllers without the need for a new HTTP request. This is very rarely useful in my opinion, other than for things like calling a custom 404 page or "widgets".

    MMVC adds barely anything to performance, calling a controller via HMVC is obviously almost twice as slow.

    Either way neither will be noticeable. If your site is starting to crawl under high traffic then this is one of the last things you'll need to worry about.