PHP5 parameter configuration for memory_limit

Source: Internet
Author: User
In PHP5, The memory_limit settings have been expanded from the previous 8 m to the upper limit of M. The definition in the configuration is as follows: memory_limit128M; Maximumamountofmemoryascriptmayconsume (128 MB) Maximum Independent memory usage of a single thread. That is, a web request that gives the thread the maximum memory usage

In PHP5, The memory_limit settings have been expanded from the previous 8 m to the upper limit of M. The definition in the configuration is as follows: memory_limit = 128 M; Maximum amount of memory a script may consume (128 MB) Maximum Independent memory usage for a single thread. That is, a web request that gives the thread the maximum memory usage

In PHP5, The memory_limit settings have been expanded from the previous 8 m to the upper limit of M.
The definition in the configuration is as follows:
Memory_limit = 128 M; Maximum amount of memory a script may consume (128 MB)
Maximum Independent memory usage for a single thread. That is, a web Request defines the maximum memory usage of the thread.
In most existing websites or forum applications, application software is generally set up in the following form:
Nginx (Apache) PHP Memcache Mysql
I will not talk about the advantages of the above application software. However, Memcache is used to reduce the frequency of database access and improve service response. However, the difference between memcache and database data storage is that memcache data is not stored in the memory in the form of the above data, but is abstracted and then in the form of characters, the hash table is stored in memory. As a result, every time memcache extracts data, all data must be in reverse order and imported into an independent single thread, the second part is to filter and extract the data you need.
In the application process, if you want to read data from the database, you should know that the optimization method should be to ensure that the first filter in the SQL statement is as accurate as possible, and only the required fields are used, do not retrieve all the fields and then filter them out in the application to obtain the desired fields, which is essentially different for the server load.
If memcache is used, it is impossible for the database to precisely filter this target for the first time. Therefore, we need to consider this when designing tables. We should try to ensure that the data in the memcache data table is as small as possible and can be completed in multiple table shards.
Memory Allocation for memory_limit, standard 128 M.
If the number of independent threads exceeds 128 MB, the following error occurs in PHP:
Fatal error: Allowed memory size of 33554432 bytes
For 8 GB memory servers, if the concurrent response reaches 50 at the same time, each of which is a peak of MB, it is estimated that the server will be stuck.
Try to reduce the memory configuration by MB. If it is adjusted to 64 MB, the server load can be reduced by about half. If it can be adjusted to 32 MB, the effect is better.
However, the requirements for applications are higher, and this issue is not taken into account in the initial stage of many tables. If you want to use memcache for data storage, you must optimize the design and deployment of data tables in advance, reducing the memory usage of independent threads PHP, server response and load reduction is not only a few percentage points.

Original article address: PHP5 configuration memory_limit parameter explanation (conversion), thanks to the original author for sharing.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.