Php, followed by mysql, when there are more than 20 users, the access is very slow. Which of the following experts can know the reason? Pay-as-you-go
Source: Internet
Author: User
Php, followed by mysql. when there are more than 20 users, access slows down. who knows why? I have made such an application, but now I cannot solve it. I am worried about it for N days. if I have a master, I can pay for it to help solve it. For details, contact qq24508609. Do not delay your time. When there are more than 20 users in web servers, php, and mysql, the access speed is very slow. who knows why? Pay-as-you-go
I have made such an application, but it cannot be solved now. I am worried about it for N days. if you have a master, you can pay for it.
Contact qq 24508609 for details. Do not delay your time.
For web servers, the network speed is about 1 MB. is it related to the network speed?
You can help me analyze the problem or contact me directly. thank you again.
------ Solution --------------------
There are many reasons for slow speed.
Let's talk about two things I have ever met.
1. it is related to the table structure. when there are many records in the table, if the corresponding index is not properly created, the SELECT process will be extremely slow.
2. it is related to the SELECT statement. when selecting a large table, try not to use *. when counting the same number of items, do not use * for the count () function, specifying a field saves a lot of cost.
------ Solution --------------------
Not even reading the database is slow.
------ Solution --------------------
20 users are slow?
No, either it's about the SQL statement written on the first floor or the structure of your program!
------ Solution --------------------
In this case, you need to analyze the program,
First, check whether your SQL statements run slowly? The running time in the local database can be seen. if it is less than 1 second, it will not be for this reason;
Second, the cause of the program is that a page is slow, which does not slow down all pages. then, analyze slow pages;
Third, the network is slow, but there are not many specific solutions. test the method to see if the static page is slow to open?
Fourth, the server is slow, that is, the configuration is too low or poisoned;
Fifth, I haven't thought of it yet...
------ Solution --------------------
As I said above, test it step by step to see where your problem is. Find out the cause of the slowness, and you can do it.
------ Solution --------------------
Q: What database are you using when creating a table in MySQL? There are InnoDB, MyISAM, and so on.
If it is not MyISAM, for example, InnoDB supports transactions. if you do not have a begin transaction or COMMIT, a new TRANSACTION is started every time you perform an insert or modify action, you may be slow in the overhead of enabling and disabling transactions. How can I change the data table back to MyISAM first?
If it is still slow, you need to check the SQL statements in your operation table before you can draw conclusions. it is very likely that the efficiency of your query statements is too low, especially when cross-table operations are performed, the connection process, or the comparison process is repeated multiple times, resulting in a rise in the number of queries to a geometric level.
For example:
SELECT * FROM xxxx WHERE abc not in (SELECT * FROM yyyy WHERE yyyy. cde> xxxx. abc)
Wait, this is just an example. the number of times the preceding query is performed is count (xxxx) * count (yyyy). if the data volume of both the xxxx table and the yyyy table is calculated in ten thousand, if you iterate over a similar structure several times, this number may be an astronomical number.
Of course, this situation also occurs in the process of self-iteration, such:
SELECT * FROM xxxx AS t1 WHERE abc not in (SELECT * FROM xxxx AS t2 WHERE t1.cde> t2.abc)
Check the code more. if not, paste the code.
------ Solution --------------------
Check whether there are Trojans.
------ Solution --------------------
Is there a limit on the number of users?
------ Solution --------------------
What system is your server? In the job manager for windows, run the top command in linux to check the cpu usage of your mysql and apache instances.
If mysql always occupies a high cpu, it indicates that some of your SQL statements are faulty.
When your website suddenly becomes slow, you repeatedly execute the show variables command in the mysql command line to check which SQL statement your mysql is executing. After you see the SQL statement, you can optimize it.
Open my. cnf (my. ini), and add log-slow-queries = slow. log, and then view the log file, which records all the slowest SQL statements executed by your website. Optimized one by one.
------ Solution --------------------
In addition, your 1 Mbps bandwidth is also a big problem. you need to find some software to test the network card traffic and test the traffic required for 20 people to access your website.
------ Solution --------------------
Suddenly I came up with a question: xp has made tcp connection restrictions. will you be xp?
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