Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php memory how much is too much

I'm currently re-writing my site using my own framework (it's very simple and does exactly what I need, i've no need for something like Zend or Cake PHP). I've done alot of work in making sure everything is cached properly, caching pages in files so avoid sql queries and generally limiting the number of sql queries.

Overall it looks like it's very speedy. The average time taken for the front page (taken over 100 times) is 0.046152 microseconds.

But one thing i'm not sure about is whether i've done enough to reduce php memory usage. The only time i've ever encountered problems with it is when uploading large files.

Using memory_get_peak_usage(TRUE), which I THINK returns the highest amount of memory used whilst the script has been running, the average (taken over 100 times) is 1572864 bytes.

Is that good?

I realise you don't know what it is i'm doing (it's rather simple, get the 10 latest articles, the comment count for each, get the user controls, popular tags in the sidebar etc). But would you be at all worried with a script using that sort of memory getting hit 50,000 times a day? Or once every second at peak times?

I realise that this is a very open ended question. Hopefully you can understand that it's a bit of a stab in the dark and i'm really just looking for some re-assurance that it's not going to die horribly come re-launch day.

EDIT: Just an mini experiment I did for myself. I downloaded and installed Wordpress and a default installation with no extra add ons, just one user and just one post and it used 10.5 megabytes of memory or "11010048 bytes". Quite pleased with my 1.5mb now.

like image 944
Rob Avatar asked Apr 06 '10 14:04

Rob


People also ask

What is a good PHP memory limit?

The right one for you depends on your system configuration. A typical appropriate memory limit for PHP running Drupal is 128MB per process; for sites with a lot of contributed modules or with high-memory pages, 256MB or even 512MB may be more appropriate.

Is PHP memory limit per process?

Memory Limit is Not The Same as RAM While RAM is the total available memory, the memory limit is per PHP process. That means that your site can consume e.g 10 GB of RAM, with a memory limit of 256 MB. We do not limit the amount of RAM you can use, just the memory limit.

How do I check my PHP memory limit?

php $memory_limit = ini_get('memory_limit'); if (preg_match('/^(\d+)(.)$/

What is a good memory limit for WordPress?

What is the recommended PHP memory limit in WordPress? WordPress has a 32MB memory limit by default, but some hosting providers increase this to 64MB for all customers. It's also possible to go even bigger — all the way up to 256MB.


1 Answers

Memory usage values can vary heavily and are subject to fluctuation, but as you already say in your update, a regular WordPress instance is much, much fatter than that. I have had great troubles to get the WordPress backend running with a memory_limit of sixteen megabytes - let alone when Plug-ins come into play. So from that, I'd say a peak of 1,5 Megabytes performing normal tasks is quite okay.

Generation time is extremely subject to the hardware your site runs on, obviously. However, a generation time of 0.046152 seconds (I assume you mean seconds here) sounds very okay to me under normal circumstances.

like image 155
Pekka Avatar answered Oct 18 '22 02:10

Pekka