Why is access to the same project sometimes fast or slow? Yii is used.

Source: Internet
Author: User
Why is access to the same project sometimes fast or slow? The Yii Post was last edited by acc972 at 11:28:24 on.

Yii PHP

When accessing a project, such as http: // host/module/controller/action
Js, img, and css files can be loaded within 0.2 seconds, but the html of View files can be loaded within 0.2 seconds sometimes, sometimes it takes more than 2 seconds or even 30 seconds to complete loading. This happens when I access this address for the first time, or when I access another view under this controller, such as http: // host/module/controller/anotheraction and then re-access the action address. in this case, not only the action address, but also the anotheraction address may occur. Is this the reason for my code? I use CDbCriteria as a data provider.


Reply to discussion (solution)

Slow access for the first time and fast access for the second time. This is generally because the cache is directly read for the second time.

So you should focus on why (for the first time) it will slow down.

Whether too many or not excellent SQL statements are used

Slow access for the first time and fast access for the second time. This is generally because the cache is directly read for the second time.

So you should focus on why (for the first time) it will slow down.

Whether too many or not excellent SQL statements are used
The cache is not used. the "first" and "second" here are actually just a form of explanation. it can be understood as "intermittent" slow access.

Change your mind

When you access a page with enough content, for example, if PHP does not perform any operation, will the front-end page be occasionally slowed down by only 123?

If not, it means that the code on your page has problems and key code is sent for analysis.

If this happens, it will be slow, so consider other ideas.

Database access is fast and slow, which is a normal phenomenon, especially in a standalone test environment.

The operating system suspends the idle service (or even moves it to the hard disk to release the memory occupied by it)
If mysql is moved to the hard disk when you initiate an access request, it will take a little longer to read from the hard disk and restore the site.
In a website officially operated, it will not be suspended because it is always accessed by someone. Therefore, the results will be satisfactory.

Database access is fast and slow, which is a normal phenomenon, especially in a standalone test environment.

The operating system suspends the idle service (or even moves it to the hard disk to release the memory occupied by it)
If mysql is moved to the hard disk when you initiate an access request, it will take a little longer to read from the hard disk and restore the site.
In a website officially operated, it will not be suspended because it is always accessed by someone. Therefore, the results will be satisfactory.

What hurts is that this situation occurs in the case of formal operation, which is very serious. The code is also checked, which is not a problem.
Because this project has a certain degree of timeliness, the database uses the master database of the Internet, and read and write operations are the master database, but only a few people are using this project, and the operation is not very frequent. Other projects also frequently access the database, but they all perform read/write splitting.
Surprisingly, for example, there is a "category management" menu under this project. the link points to a view page displaying classified data. the category table contains only five fields and 10 records, the query display should be very fast. But sometimes it may take several seconds or even minutes to open this page!
I also checked the slow query log. it takes 15 seconds for an SQL statement like this to be queried. "UPDATE history SET status = '123 ', time = 1373254836, t_id = '34' WHERE id = '000000'; ", solving ..

Do you have many updates?

Will it cause the lock table, so it is very slow?

Do you have many updates?

Will it cause the lock table, so it is very slow?

Today, I opened CWebLogRoute to check the execution of the program. there is a new clue.


I just found out that it's up, and there's no reason yet.

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.