Jump to content

Efficiency/running time question


Agum

Recommended Posts

I'm working on a project and I anticipate the traffic to be fairly high when it's done.

There is almost no static pages so every page hit is a php script execution basically.

 

Because the application is fairly complex, I am designing it in an OO approach. Some core classes will get fairly large when they are done -- maybe 100kb~ each for 2 of the classes' code (initial version). These are the core objects that are used by basically every php script. (and as time goes, there'll be more enhancements so it can only increase more)

 

Is efficiency/server load/running time something I should have to worry about? It's a very interactive web application (employing a lot of AJAX, and even full page loads are fairly frequent) for every user, and I anticipate to have hundreds of users at the beginning, soon to grow to thousands. With source files/classes of such sizes, do you think that's an issue? (the point is, every interaction requires loading all these classes [probably 4~5 classes], executing at least a few methods in each)

 

(I'm not really extremely familiar with how PHP handles memory management and code execution, so maybe something of this size is entirely reasonable and not a problem. I just want to know.)

Link to comment
Share on other sites

Efficiency is always something you should mind. It's hard to say whether your script/site/application will run efficiently. Whether it is an issue to load a lot of things depends on what those "things" do. If it is e.g. very CPU intensive tasks, then it might be a problem. You could try using some profilers, which will show what things that take up most time in your script execution. There is e.g. a profiler built into Zend Studio.

Link to comment
Share on other sites

100kb for a class?

 

Too big. Period.

 

Would it really do any difference in terms of performance?

 

That's the real question -- since they are all methods definitions (implementations), technically if they aren't called, the code doesn't execute. So it should just be loaded in memory and nothing else, right? If that's the case, does that affect performance by much?

Link to comment
Share on other sites

When ever a PHP script is called, the entire script is compiled, but a 100KB file should be able to be compiled in an unnoticeable time....

 

Like Daniel0 said, it really just depends on what each class is doing....

 

My advice would be, if possible, extend classes so you don't have to load a 100KB file on a page that's gonna use 1 method....

Link to comment
Share on other sites

The object will be carrying all that 100kb of class data with it, whether you use it or not.

 

Would you take an 18 wheeler to collect your morning newspaper from the shop which is only 100m away?

Link to comment
Share on other sites

Maybe he needs to take out his trash, grab a cup of coffee, drop off a kid and stop by the post office on the way there ;p.

 

(Doesn't follow your truck thing since the size... but you get what I mean....)

 

and was "The object will be carrying all that 100kb of class data with it, whether you use it or not." aimed at me?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.