M2T Posted July 21, 2018 Share Posted July 21, 2018 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 Quote Link to comment Share on other sites More sharing options...
requinix Posted July 21, 2018 Share Posted July 21, 2018 #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. Quote Link to comment Share on other sites More sharing options...
M2T Posted July 24, 2018 Author Share Posted July 24, 2018 Thanks you.? Quote Link to comment Share on other sites More sharing options...
gizmola Posted July 24, 2018 Share Posted July 24, 2018 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.