Performance optimization question(s) |
[eluser]Myles Wakeham[/eluser]
I have a number of larger scale CI/PHP5 applications on a collection of servers. One of these applications has a pretty active user community, and uses a UI that has tabs to allow the user to enter various controllers in the application per their logical class requirements. I am getting some reports from the field that when a user moves from one tab to another, there is a 1-2 second delay. I checked on what could cause this and the only thing I can see is that each controller can load up to 10 plug-in libraries and 10-15 models. I'm pretty sure that the loading of the plug-ins isn't the issue, because they are just collections of functions and don't do anything. However I think that the loading of the models may be what is slowing down the process, as each class is effectively instantiated on load. I'm trying to get some general ideas of best practice when it comes to optimization under this situation. Clearly I want to use models, as my app is fully MVC and OO in its design. However is there a way to possibly cache the model load, or do something so that the instantiation of these models when a controller loads doesn't take so long? Are there any tricks that others have used to speed this type of thing up? Thanks in advance for any suggestions. Myles
[eluser]bretticus[/eluser]
Database queries (especially under load) will slow your app down considerably. That's why op caching alternatives exist for PHP. If you have a cluster of servers, memcache works nicely, if you have a single server, APC is easy to setup as a PHP extension. Check out Elliot Haughin's multicache library for op caching with either.
[eluser]jwindhorst[/eluser]
I really this thread is a little old, but I was just puzzling a similar question in building out a personal project. Assuming I have a companies model which pulls in company contacts and company addresses, I am debating writing the joins in the company model. In theory I think this pollutes the MVC, but in reality, it seems like the one DB hit with the joins is faster than calling the individual models for company addresses and company contacts. What are the general guiding principles for this? Is it considered taboo to cross model lines? Or, at the end of the day is it better to have the performance enhancement and let other developers suffer through the more complex queries and query locations? I suppose if it comes down to cost benefit ratio, throwing hardware at the performance issue might be cheaper. Since it's a personal project though, I'm wondering if my time is more valuable than the cost of hardware. Thoughts? |
Welcome Guest, Not a member yet? Register Sign In |