php,后面mysql,当用户大于20人左右,就出现访问奇慢的现象,哪位高手能知道原因?可付费
php,后面mysql,当用户大于20人左右,就出现访问奇慢的现象,谁能知道原因?可付费
本人做了一个这样的一个应用,现在解决不了,苦恼N天,如有高手可付费帮忙解决。
具体的可与qq 24508609联系。非高手,不要耽误大家时间。
web服务器,网速度1M左右,是否和网速度有关?
高手可帮我分析,或直接和我联系,重谢。
------解决方案--------------------
速度慢会有很多原因。
说两个我曾经遇到过的
1,和表结构有关,表记录很多的时候,如果没有正确的建好相应的索引,那SELECT出来的速度是奇慢无比。
2,和SELECT语句有关,在SELECT 大表的时候,尽量不要用*,同样的统计条数的时候count()数函数也不要用*号,指定字段会节省很多的开销。
------解决方案--------------------
不连数据库看还慢不慢
------解决方案--------------------
20个用户就很慢?
不会的,要不就是想一楼所书的SQL的问题,要不就是你程序结构的问题了!
------解决方案--------------------
一般这样的情况你需要去分析程序的,
第一,sql语句,你看看你的sql运行慢吗?本地数据库里面直接运行可以看见时间,如果低于1秒就不会因为这个原因;
第二,程序原因,那一般就是某个页面慢,不会造成所有的页面都慢的;然后分析慢的页面;
第三,网络慢,具体解决办法不多;测试方法看看静态页面打开慢吗?
第四,服务器慢,那就是配置太低或者中毒了;
第五,还没有想到。。。
------解决方案--------------------
就如楼上说的,一步一步测试, 看你的问题出在哪里. 找到慢的原因了,就好办了.
------解决方案--------------------
问一个问题,MySQL中建表,你使用的是什么数据库?有InnoDB或者MyISAM等等类型
如果不是MyISAM的话,比如InnoDB支持事务,如果你没有BEGIN TRANSACTION和COMMIT,每做一个插入或者修改动作就开启一个新的事务,你很可能慢在事务开启和关闭的开销上。你先把数据表改回MyISAM试试?
如果还是很慢,需要看看你操作表的SQL语句才能下结论,很可能你做查询的语句效率太低,特别是跨表操作的时候,连接的过程,或是比较的过程做了多次重复计算,导致查询量成几何级数上升
比如:
SELECT * FROM xxxx WHERE abc NOT IN (SELECT * FROM yyyy WHERE yyyy.cde>xxxx.abc)
等等,这只是一个例子,上面这个查询要做的次数就是count(xxxx)*count(yyyy)次,如果xxxx表和yyyy表的数据量都是以万来计算的话,如果类似的结构你再多迭代几次的话,这个数字可能是天文数字
当然,这种情况也发生在自我迭代的过程中,比如:
SELECT * FROM xxxx AS t1 WHERE abc NOT IN (SELECT * FROM xxxx AS t2 WHERE t1.cde>t2.abc)
你多检查检查吧,实在不行就把代码贴上来好了
------解决方案--------------------
应该看一下有没有木马。
------解决方案--------------------
是不是用户数目做了限制?
------解决方案--------------------
你的服务器什么系统?windows的话在任务管理器里面看,linux用top命令查看你的mysql和apache各占多少cpu。
如果mysql占的cpu总是很高,就说明你的某些sql有问题。
当你的网站突然变得很慢时,你在mysql的命令行中反复执行SHOW VARIABLES命令,查看一下你的mysql正在执行哪条sql语句。看到sql语句后,你可以对这条sql语句进行优化。
打开my.cnf(windows下为my.ini),加上log-slow-queries = slow.log,然后去查看这个log文件,里面记录的全都是你的网站执行的最慢的sql语句。逐一优化。
------解决方案--------------------
另外,你1m的带宽肯定也是个很大的问题,你找一些测试网卡流量的软件,测一下20个人访问你的网站大概需要多少的流量。
------解决方案--------------------
突然想到一个问题,xp做了tcp连接限制,你会不会是xp阿?
http://download.it168.com/02/0222/50167/50167_3.shtml

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

Apache connects to a database requires the following steps: Install the database driver. Configure the web.xml file to create a connection pool. Create a JDBC data source and specify the connection settings. Use the JDBC API to access the database from Java code, including getting connections, creating statements, binding parameters, executing queries or updates, and processing results.

The process of starting MySQL in Docker consists of the following steps: Pull the MySQL image to create and start the container, set the root user password, and map the port verification connection Create the database and the user grants all permissions to the database

The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

The key to installing MySQL elegantly is to add the official MySQL repository. The specific steps are as follows: Download the MySQL official GPG key to prevent phishing attacks. Add MySQL repository file: rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm Update yum repository cache: yum update installation MySQL: yum install mysql-server startup MySQL service: systemctl start mysqld set up booting

Laravel is a PHP framework for easy building of web applications. It provides a range of powerful features including: Installation: Install the Laravel CLI globally with Composer and create applications in the project directory. Routing: Define the relationship between the URL and the handler in routes/web.php. View: Create a view in resources/views to render the application's interface. Database Integration: Provides out-of-the-box integration with databases such as MySQL and uses migration to create and modify tables. Model and Controller: The model represents the database entity and the controller processes HTTP requests.
