About the PHP optimization speed problem, the file cache, the impact will be large?

Source: Internet
Author: User
Cache optimized PHP Data

Due to limited conditions, there is no memcache, but many places such as "regional information, various tree classification, global menu link" and so on information, directly from the database, it is really too slow, and a page down the statement too much, so adopted a method, is to save this kind of data directly to the hard disk, Read it directly from the hard drive when needed.

Project done almost, found that the use of such methods of the place seems to be a lot, now is the gall heart to the time when the official on-line, too much reading will be directly hung up?

There is no experience in this area, give the reply. The current words, I test the speed is pretty fast, but after all, no pressure.


Reply to discussion (solution)

I have a tool to do under the stress test, see the IO can not hold. Make a cache quickly ah, a casual on the can, and not difficult

No memcache can build a memory table with MySQL. or increase the MySQL cache also works.

The best thing is to read the memory is the cache in memory in the specific is LS said and file on the hard disk--feel and read the database 50 Step 100 Step Difference hard disk is a bottleneck.

Because of the limited conditions, there is no memcache, but many places such as "area information, various tree classification, global menu link" and so on information, directly from the database, it is really too slow

It's best to optimize your queries and programs.

I?? Describe what I have done:
My site has a huge classification table, which is divided into multiple layers, each of which stores the number of news in the category.
To prevent the classification table from being re-read every time, I set up a function that will only be called when the news is added, and his role is to read each category and calculate how many news are in each category. After the calculation is finished, the classification is re-assembled into an array, and then use this function to put my array into a PHP file, so the foreground in the display only need to require this PHP file to come in and then traverse the array output, there is no need to re-read the database.
That is, the database in advance to read the classification of the integration into an array into a PHP file, displayed when the PHP file is require, do not need to read the database every time.

The project is almost done, in this case, if you do not want to make a fuss of the code, the best way to add the intermediate cache layer, if not involved in the server cluster, you can open the server side eaccelerator, APC, xcache cache opcode Open, If it's a server cluster, you need to be on the reverse proxy.

Due to limited conditions, there is no memcache.
This sentence is not very clear, memcache also do not need the server has how high configuration.
Also, according to your current reading procedure, you can use JMeter and so on to measure the pressure test, a lot of tools for stress testing.
Io in time now no problem, with the increase in access, bottlenecks or it ...
No matter how to change, it is recommended not to make big changes, do not affect the current function.

Can be taken out the first time to write a file storage, and then read the time to read the file directly, if the data has been modified to re-write, many frameworks do this

The memory table is sufficient ...

I'm usually a file store plus memcache to look at data content

You can use JS to do a local cache

It is recommended that you use the MySQL query cache. This is the most available, flexible, transparent way. This requirement, performance is not necessarily very demanding.

My point is, memcache this thing is suitable for exchanging data between two sessions (pages), not for caching.

  • 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.