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.
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.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 application, 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.