

Ask HN: With PHP and APC, what is better? - EGreg

Hey guys, does anyone here know whether it's better to have lots of small PHP files or one large PHP file, when APC is enabled? I am talking in terms of<p>1) Memory used
2) Speed of loading<p>It seems to me that multiple small files are always better, once you turn off doing "stat" on files... because you load only what you need to handle a request. But perhaps I am missing something, and loading a file is still more expensive?<p>I tried to get the information elsewhere but to no avail so far. Maybe Rasmus Lerdorf lurks here :)
======
Travis
As in nearly all performance metrics, your mileage will vary (greatly).

At some point I'm sure that the cost of loading external files will outstrip
the benefit gained from not having it in memory. You need to test this in your
application. It should be pretty simple -- just write everything in separate
files. When you feel you have enough done to accurate represent a
(performance) profile of your site, do load tests. Then concat all the files
together, and do a load test on that.

In short, it's time we start thinking about performance as a result of
architecture crossed with implementation. This means you have to include your
specific business logic and data models in your implementation. You can't
evaluate scalability issues without doing some testing in your specific case,
if you want the results to have any meaning.

