What is the best value for PHP’s memory_limit with 4GB of memory?

Asked

Viewed 621 times

0

I have a server cloud dedicated, with 4GB of RAM and 4 colors of 1.2GHz.

I have an extremely robust system running and would like to know the amount of memory to set in memory_limit in PHP 5.5?

  • Ever had a problem with default value? vc can set a different value from the default php.ini in the script for the most critical cases.

  • Nothing else on the server? Database?

  • @lost, I know where. The problem is the calculation to estimate memory usage for PHP.

  • @bfavaretto, no, just PHP running on this server. Thank you! ;-)

1 answer

1

In scripts that have a more robust logic, where the memory consumption is higher, enter the following, to perform tests and know the memory consumption that a user has on his server, and multiply this by the amount of simultaneous accesses that his system usually has.

// We start the "counter"

list$Usec, $sec) = explode(' ',microtime());
$script_start = (float) $sec + (float) $Usec;

/* YOUR PHP CODE */

// We finished the "counter" and displayed
list($Usec,$sec) = explode(' ', microtime());
$script_end = (float) $sec + (float) $Usec; $elapsed_time = round($script_end - $script_start, 5);

// We show a message

echo 'Elapsed time: '. $elapsed_time. ' secs. Memory Usage: '. round(((memory_get_peak_usage(true) / 1024) 2). 'Mb';

Browser other questions tagged

You are not signed in. Login or sign up in order to post.