Why is it sometimes very slow when you visit the same project? Yii is used.

Source: Internet
Author: User
This post was last edited by acc972 on 2013-08-07 11:28:24

Yii PHP

On a project such as Http://host/module/controller/action
, JS, IMG, CSS, etc. can be loaded within 0.2 seconds, but the view file HTML can sometimes be loaded in 0.2 seconds, sometimes it takes more than 2 seconds or even 30 seconds to load complete. This happens when I first visit this address, or when I access another view under the controller, such as Http://host/module/controller/anotheraction, and then re-access the action address, And this situation is not only present in the action address, it is possible to occur on anotheraction. Excuse me, is this the reason for my code? I use Cdbcriteria as a data provider.


Reply to discussion (solution)

First visit slow second faster this is typically because the second time the cache is read directly

So you should focus on why (the first time) is slow

Do you use too many or less-than-good SQL statements

First visit slow second faster this is typically because the second time the cache is read directly

So you should focus on why (the first time) is slow

Do you use too many or less-than-good SQL statements
Not using the cache, here the "first" and "second" is actually just a metaphysical statement, understood as "intermittent" access slow

Then change the idea.

You have access to a page with enough content, such as PHP, without any calculations. The front page is only a 123 and occasionally super slow?

If not, that's you. The page code has a problem with the key code to analyze

If it's going to be slow, then consider other ideas.

It is normal to have a fast and slow access to the database, especially in a stand-alone test environment

The operating system suspends the idle service (or even moves it to the hard disk, freeing up its occupied memory)
If you launch a visit, it happens that MySQL is moved to the hard drive, and there's a job that reads from the hard drive and resumes the scene, and of course it takes a little more time.
On a website that's officially running, it's always going to be suspended because someone is always accessible. So the effect will be satisfactory.

It is normal to have a fast and slow access to the database, especially in a stand-alone test environment

The operating system suspends the idle service (or even moves it to the hard disk, freeing up its occupied memory)
If you launch a visit, it happens that MySQL is moved to the hard drive, and there's a job that reads from the hard drive and resumes the scene, and of course it takes a little more time.
On a website that's officially running, it's always going to be suspended because someone is always accessible. So the effect will be satisfactory.

The egg ache is that this happens in the case of a formal operation, which is very serious. The code aspect is also checked, the problem is not big.
Because this project has a certain timeliness, so the database with the external network of the main library, read and write operations are the main library, but only a few people in the use of this project, the operation is not particularly frequent. Other projects also have frequent access to the database, but both read and write separation.
Oddly, under this project, for example, there is a "category management" menu, linked to a display of categorical Data View page, the classification table only 5 fields 10 records, the query is displayed should be very fast. But sometimes it can take a few seconds or even minutes to open this page!
I also looked at the slow query log, like a SQL statement in which his query time will be used to 15 seconds, "UPDATE history SET status= ' 1313 ', time=1373254836,t_id= '" where id= ' 817 ' ; ", Solving:

Do you have a lot of update?

Could it be that it caused the lock table so slow

Do you have a lot of update?

Could it be that it caused the lock table so slow

Open Cweblogroute today to see how the program is performing, with new clues


I just found it, it's up, it's not starting.

  • Related Article

    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.