views:

58

answers:

3

Hello all,

I have switched on the Codeigniter profile (very useful) and I have noticed that a page of mine shows the memory used as:

2,405,496 bytes

That's ~2MB and it's for one request - does it mean if 1000 users accessed this page at the same time, memory usage will be 2GB?

Have I got my maths wrong or is there more to this than just multiplying two numbers?

Thanks all for any help

EDIT

Is this sort of memory usage normal for a script running 2 simple select queries? I do autoload helpers such as form, url and also Database and session classes.

+1  A: 

Yes, but most likely you wont have 1000 users accessing your page at the very exact same instant. It will be spread out over a few seconds/minutes/etc. Plus I doubt your webserver could even handle 1000 concurrent connections.

davr
+4  A: 

2MB is not that much -- it doesn't look surprising to me, at least ; I often see much higher values, when using a framework, even if not doing lots of SQL queries.

Note that the memory_limit, which defines how much memory a PHP script can use, if often set to at least 8MB -- and quite often 16 or even 32 MB.


1,000 users at the same time ?

First of all, are you sure your application will be successful enough to have one thousand users requesting a page at the same time ?
Note that if you need need 1 second to generate a page (which is already a bit long), it means having 1,000 users requesting a page in that one second !

Then, anyway, your server will probably never support that load -- by default, I should add that Apache is generally configured to not serve more than something like 200 concurrent requests.

If you really expect to have 1,000 users at the same instant on your applicatio, you'll have plenty of other problems, I'd say -- and you'll probably have to optimise a lot, and/or use more than one server.

Pascal MARTIN
1000 users at the same time is a bit fanciful but nothing wrong with trying to build an application that can scale with that sort of traffic in mind! :) I was just surprised with the memory usage, shows that this is probably the first time I have looked at memory usage for one particular script.
Abs
+1  A: 

With my grammar school math.

1000 rps is equivelant to
86400 * 1000 = 86400000 views per day 
which is also equivalent to 
2592000000 views per month. 
which is 2592 MILLION page views per month. 
Or , 2.5 BILLION page views per month.

So you are talking about a website more popular than linkedln, which gets 1.9 billion views per month.

Do you think linkedln runs in one box?

Helpful answer:

I average about 3MB in my CI applications. Havent done any aggressive optimization, but I think you should be happy with your 2MB figure.

Iraklis
You grammar school math isn't that bad - thanks for putting it into perspective for me.
Abs