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
  • Hi Michael, I don't think so... really what I am looking for is someone with more in-depth web-server experience than I have (which is not asking much...) to chime in with, "Apache will handle serving a single file to millions of users just fine," or "Break it up into pieces and it will do much better..." Something to that effect. :) – Raconteur Aug 14 '12 at 20:19
  • 1
    I don't think it's possible for any of us to say how well your application will perform with one design as opposed to the other. The best advice I can give you is to try it both ways and see. – Michael Hampton Aug 14 '12 at 20:24
  • So there is really no "rule of thumb" that says that a server will handle serving separate files to multiple users better than serving a single file to multiple users (or vice-versa)? Seems like it would be one of those server-admin secrets. :) – Raconteur Aug 14 '12 at 21:10
  • It would be helpful if you could define exactly what you mean by "metric." Since you have this tagged as Amazon Web Services, have you looked at using [custom CloudWatch metrics](http://aws.amazon.com/about-aws/whats-new/2011/05/10/amazon-cloudwatch-announces-custom-metrics-lower-prices-for-amazon-ec2-monitoring/)? Or possibly [SimpleDB](http://aws.amazon.com/simpledb/)? Also: You shouldn't be running anything other than a test environment on a single EC2 instance. A production environment should *always* be composed of at least two EC2 instances. – jamieb Aug 15 '12 at 00:27

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
  • 715
  • 3
  • 8