Link Details

Link 115483 thumbnail
User 111696 avatar

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.
  • 9
  • 1
  • 1264
  • 401

Comments

Add your comment
User 233461 avatar

antych replied ago:

0 votes Vote down Vote up Reply

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.

User 287383 avatar

phpimpact replied ago:

0 votes Vote down Vote up Reply

True

User 276794 avatar

Loïc Hoguin replied ago:

1 votes Vote down Vote up Reply

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.

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Voters For This Link (9)



Voters Against This Link (1)