0

Possible Duplicate:
How do you do Load Testing and Capacity Planning for Web Sites

I hope this is the proper place to ask this. I put it up in webapps and it was closed without a recommendation on where to put it. Hopefully folks will be kinder here.

I have an app that I am gathering usage metrics on. The metrics are sent to a MySQL DB via PHP scripts. This is all running on an AWS EC2 micro instance.

My question is, I have about 10 metrics I want to gather. Would I be better served breaking up the PHP scripts into 10 separate units that each write one metric to the DB or writing one monolithic PHP script to handle them all?

I don't care about the complexity or inherent difficulty maintaining 10 scripts, what I am concerned with is the scalability for a TON of users. Is it generally better to have more scripts to serve many people, or one script to serve many people? Basically if 10 people use our app, each hitting a different metric, one method would serve the same page 10 times, and the other would serve a single page once to each user.

Which performs better??

Thanks for any input!

Chris

Raconteur
  • 101

1 Answers1

0

First of all, I believe this site (ServerFault) is the proper place to ask your question, as long as you're concerned about how to configure and deploy your web server (SF is a system admin place). If it turns out you have more of a coding question (how do I do this properly in php) then you might post that to StackOverflow, which is intended more for programming issues.

But to your main question, the answer is unfortunately, It Depends(tm). One significant distinction between your original question and your discussion in comments, using PHP to post updates to a database is significantly different than serving one file or multiple files out of a webserver. The reason for this is that a well-configured php application will run inside of the webserver process (ie mod_php in Apache) and so will soak up CPU time from the webserver, and the PHP binary's libraries will get loaded up into memory as well.

However, those are the "buy in" costs of running your web application. They are not going to change significantly whether you have a single PHP script with dispatch logic, or a bunch of different single-purpose scripts.

To make a really broad generalization, the slowest and most resource-hungry part of many web applications is the step where they connect to the database. This is the reason there are so many application frameworks, tightly integrated with web or app servers: to take advantage of resource pooling for those expensive setup tasks. Again, assuming you run your application in Apache with mod_php, this is likely to be handled for you automagically or at least made quite simple.

khoxsey
  • 725