Hello. I understand not especially in Linux, at the level of implementation by manuals. It took to raise your vps server. I found a suitable host on the debian server with a very minimal config: cpu 1 core 0.6 Ghz, 384 RAM. Approximately 30-50 users contact the server every 10 seconds, and quite often in php-log you see this:

PHP Fatal error: Out of memory (allocated 262144) (tried to allocate 261900 bytes) in Unknown on line 0

sometimes I can't even connect via ftp or via putty because there is not enough memory.

And most importantly, I do not understand why there is not enough memory if, when viewed in the 'top', it shows approximately that another 200 meters is free : Mem: 393216k total, 159172k used, 234044k free.

scripts and queries to the database are not particularly loaded, the execution speed is high. googling, chopped off innodb in mysql, and slightly changed the values ​​of ServerLimits.

Here is a screen from the "top", can someone tell me something? Is 40 users really such a strong load? http://i6.imageban.ru/out/2014/07/07/22f3ad865de9029e8dbafc036596d107.png

  • one
    The solution is only one. Buy a more powerful server - Bastian
  • one
    @deivan a question of checkers and trips - etki

3 answers 3

@ snake22 , messages of this kind say that the memory is used up to the maximum specified in php.ini. Accordingly, this bar can be raised, bottlenecks can be optimized.

ps for some reason it always seemed that this is the limit of memory for one script that processes one request. Look, where exactly PHP falls, maybe there is a wild consumption of memory.

upd

tried to allocate 261900 bytes

The script tried to grab 262 MB of memory just like that, because it can. Look for a bottle throat.

  • but what about this moment: "sometimes I can’t even get by ftp or putty because there is not enough memory." ? that is, it is not only related to PCP, and also, in php.ini, the limit is worth memory_limit = 32M I sometimes come into putty trying to start the same top and write something like (I don’t remember exactly) Cannot allocate memory and something there about fork. I will check the scripts again, but everything is so simple that there should be no memory leaks. ps not 262Mb but 262 kilobytes) - snaked3
  • one
    > Cannot allocate memory and something about fork. So, when trying to do something, the system itself rests on the resource constraints for its internal processes. You also have all the logs, see /var/log - there are a lot of interesting things. But, on the other hand, 384 RAM - IMHO, there is no need to look here. It is clear that catastrophically little for debian. - user6550
  • @ snake22, do you have root rights on this server? - If not, then except to cry, it still does not work. And if there is, then you can try to search (recall) how to solve the problem. At least in the swap you have a place. And the memory, which top shows as free - directly with memory, which m. highlighted process does not correlate (in principle, you can get more than free at the moment). - avp
  • @ snake22> in ppp.ini limit is memory_limit = 32M This is for one script. With multiple connections, the memory consumption is, of course, multiplexed. there are usually a lot of these initiators (one for each sapi), make sure you work with the right one - etki
  • @klopp but why not enough? if even in the server’s control panel at the hoster, to see, in the RAM Usage graphics, the memory does not exceed 170Mb. Maybe I do not know something in Linux and there is some kind of artificial restriction? There is a root, I can provide all the logs if necessary - snaked3

Why there is not enough memory if, when viewed in the 'top', it shows approximately that another 200 meters is free

  1. Who said that everything that shows top can be captured by your php scripts?
  2. The moment of capture may not coincide with the update of the top.
  3. 261900 in any case more than 234044
  • as far as I understood 261900 bytes and 234044k - kilobytes. that is, it turns out that in this case 234044k is more than 261900b - snaked3

VPS VPS'u discord. You didn’t even say what kind of virtualization system you use (OpenVZ, KVM, Xen, Hyper-V, etc) Maybe your hoster "cheats" and sells resources somewhat more than it actually is ( overselling ). Also, the bit depth and OS version are not indicated.

And so it is probably worth thinking about and buying a typewriter.