Jump to content

some questions about php.ini and my.ini php mysql settings


Recommended Posts

Hi.

I want configure and optimize a vps server.

Please help me.

; Maximum amount of memory a script may consume (128MB)
memory_limit=128M

You suppose we have just one PHP file: index.php.

We have 100 users simultaneously (all 100 user exactly in a moment request this single php file) , and we set memory_limit=128M which is correct:

1- only 128MB of physical memory use by PHP even if simultaneously we have 100 user.

2- 100*128MB =12800MB of physical memory use by PHP

Thanks

Link to comment
Share on other sites

#2.

Settings apply per request, so 100 requests means potentially 100*128MB in use. However realistically those 100 will be spread out over the full second, and if your script takes 0.1s to execute then that's (100*0.1)*128MB. And of course your script shouldn't actually be taking nearly that much - the setting is really more to prevent something really bad from happening, since hitting that limit means your script will die.

Link to comment
Share on other sites

In order to analyze your memory use more effectively we also need to know if you are using Apache with the php module, or alternatively some other configuration (the typical alternative is nginx with php-fpm).

The thing to understand about memory_limit is that it is not an allocation parameter, but rather hard limit.  

If your PHP script needs 5mb it will get 5mb.  If it needs 128, it will get that.   If the script needs more than 128mb, then it will hit the memory_limit setting and die, which will cause the server to return a 500 error.  

Memory use is largely determined by the architecture you are using and the memory requirements of your PHP scripts compounded of course by the load.  To really probe and understand what your VPS can sustain you have to simulate load using a load testing product.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.