By bloid
via particletree.com
Published: Sep 18 2008 / 02:38
It’s hard to imagine pushing the limits of object oriented PHP so far that your web servers choke, but the truth is those limits are reached faster than you think. We’ve run some tests over at Wufoo and it turns out that any sort of mass object creation is pretty much not going to work at scale. The problem is this limit on object creation forces developers to balance code consistency, which is desirable—especially for the old-schoolers, with performance. While replacing objects with arrays when possible makes things a little better, the most performance friendly approach involves appending strings. For your convenience, we’ve run some tests that measure page execution times and memory usage to create the following guideline to help you plan out what areas of your code may have to break away from an object oriented nature.
Comments
antych replied ago:
Default memory limit is 128MB both in php.ini-dist and php.ini-recommended. It should also be no surprise that more complex structure take up more memory.
phpimpact replied ago:
True
Loïc Hoguin replied ago:
Like was pointed out in the comments, use the Iterator interface when iterating through many rows/elements. That way there's only one row at a time in memory.
If you think you need to retrieve 50000 rows or create 50000 objects at the same time to perform an operation, think again.
Voters For This Link (9)
Voters Against This Link (1)