Php opencart电子商务站点的第一个字节时间非常长
我检查了电子商务站点的站点统计:它给出了以下报告---- 我用Php opencart电子商务站点的第一个字节时间非常长,php,mysql,nginx,opencart,Php,Mysql,Nginx,Opencart,我检查了电子商务站点的站点统计:它给出了以下报告---- 我用top命令检查了我的服务器,并检查了mysql占用了99%的CPU%时间和214:26.79的time+ 之前mysql表没有优化,所以我创建了这些表的索引。之后,加载时间大大缩短。现在我第一次面临问题。以下是mysql变量: mysql> show variables like 'innodb_buffer_pool_size'; +-------------------------+-----------+ | Variab
top
命令检查了我的服务器,并检查了mysql
占用了99%的CPU%
时间和214:26.79的time+
之前mysql表没有优化,所以我创建了这些表的索引。之后,加载时间大大缩短。现在我第一次面临问题。以下是mysql变量:
mysql> show variables like 'innodb_buffer_pool_size';
+-------------------------+-----------+
| Variable_name | Value |
+-------------------------+-----------+
| innodb_buffer_pool_size | 134217728 |
+-------------------------+-----------+
1 row in set (0.00 sec)
mysql> show variables like 'innodb_flush_log_at_trx_commit';
+--------------------------------+-------+
| Variable_name | Value |
+--------------------------------+-------+
| innodb_flush_log_at_trx_commit | 1 |
+--------------------------------+-------+
1 row in set (0.00 sec)
mysql> show variables like 'innodb_open_files';
+-------------------+-------+
| Variable_name | Value |
+-------------------+-------+
| innodb_open_files | 300 |
+-------------------+-------+
1 row in set (0.00 sec)
mysql> show variables like 'innodb_table_locks';
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| innodb_table_locks | ON |
+--------------------+-------+
1 row in set (0.00 sec)
mysql> show variables like 'innodb_thread_concurrency';
+---------------------------+-------+
| Variable_name | Value |
+---------------------------+-------+
| innodb_thread_concurrency | 0 |
+---------------------------+-------+
1 row in set (0.00 sec)
mysql> show variables like 'join_buffer_size';
+------------------+--------+
| Variable_name | Value |
+------------------+--------+
| join_buffer_size | 131072 |
+------------------+--------+
1 row in set (0.00 sec)
mysql> show variables like 'key_buffer_size';
+-----------------+----------+
| Variable_name | Value |
+-----------------+----------+
| key_buffer_size | 16777216 |
+-----------------+----------+
1 row in set (0.00 sec)
mysql> show variables like 'max_connections';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 151 |
+-----------------+-------+
1 row in set (0.00 sec)
mysql> show variables like 'max_delayed_threads';
+---------------------+-------+
| Variable_name | Value |
+---------------------+-------+
| max_delayed_threads | 20 |
+---------------------+-------+
1 row in set (0.00 sec)
mysql> show variables like 'max_heap_table_size';
+---------------------+----------+
| Variable_name | Value |
+---------------------+----------+
| max_heap_table_size | 16777216 |
+---------------------+----------+
1 row in set (0.00 sec)
mysql> show variables like 'max_tmp_tables';
+----------------+-------+
| Variable_name | Value |
+----------------+-------+
| max_tmp_tables | 32 |
+----------------+-------+
1 row in set (0.01 sec)
mysql> show variables like 'thread_cache_size';
+-------------------+-------+
| Variable_name | Value |
+-------------------+-------+
| thread_cache_size | 8 |
+-------------------+-------+
1 row in set (0.00 sec)
mysql> show variables like 'tmp_table_size';
+----------------+----------+
| Variable_name | Value |
+----------------+----------+
| tmp_table_size | 16777216 |
+----------------+----------+
1 row in set (0.00 sec)
mysql> show variables like 'wait_timeout';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| wait_timeout | 28800 |
+---------------+-------+
1 row in set (0.00 sec)
mysql> show variables like 'myisam_sort_buffer_size';
+-------------------------+---------+
| Variable_name | Value |
+-------------------------+---------+
| myisam_sort_buffer_size | 8388608 |
+-------------------------+---------+
1 row in set (0.00 sec)
我认为第一个字节的延迟主要是由于mysql
配置或opencart
框架造成的。我已经采取措施优化运行该站点的nginx。如何减少第一个字节的时间?请帮忙。我解决了这个问题。
问题在于opencart数据库索引系统。因为他们没有正确索引表-一些与product\u标记
和url\u别名
相关的查询通常需要很长时间才能执行。由于它们锁定了这些表,序列中的其他查询无法访问它们。这会为客户端接收的第一个字节造成相当大的延迟
解决方案是为所有这些查询需要相当长时间的表创建索引。我的延迟时间减少到原来的十分之一。
(有关更多信息和详细信息,请查看opencart论坛-这是OC用户经常遇到的问题)我认为这是服务器的文件系统、RAM或CPU以及一些缓存(mem、apc、query)中的一个问题-很可能第一个唯一的请求需要先缓存(这可能占用了大部分时间)然后呈现结果数据。第二个请求已被缓存。这是你的案子吗?
mysql> show variables like 'innodb_buffer_pool_size';
+-------------------------+-----------+
| Variable_name | Value |
+-------------------------+-----------+
| innodb_buffer_pool_size | 134217728 |
+-------------------------+-----------+
1 row in set (0.00 sec)
mysql> show variables like 'innodb_flush_log_at_trx_commit';
+--------------------------------+-------+
| Variable_name | Value |
+--------------------------------+-------+
| innodb_flush_log_at_trx_commit | 1 |
+--------------------------------+-------+
1 row in set (0.00 sec)
mysql> show variables like 'innodb_open_files';
+-------------------+-------+
| Variable_name | Value |
+-------------------+-------+
| innodb_open_files | 300 |
+-------------------+-------+
1 row in set (0.00 sec)
mysql> show variables like 'innodb_table_locks';
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| innodb_table_locks | ON |
+--------------------+-------+
1 row in set (0.00 sec)
mysql> show variables like 'innodb_thread_concurrency';
+---------------------------+-------+
| Variable_name | Value |
+---------------------------+-------+
| innodb_thread_concurrency | 0 |
+---------------------------+-------+
1 row in set (0.00 sec)
mysql> show variables like 'join_buffer_size';
+------------------+--------+
| Variable_name | Value |
+------------------+--------+
| join_buffer_size | 131072 |
+------------------+--------+
1 row in set (0.00 sec)
mysql> show variables like 'key_buffer_size';
+-----------------+----------+
| Variable_name | Value |
+-----------------+----------+
| key_buffer_size | 16777216 |
+-----------------+----------+
1 row in set (0.00 sec)
mysql> show variables like 'max_connections';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 151 |
+-----------------+-------+
1 row in set (0.00 sec)
mysql> show variables like 'max_delayed_threads';
+---------------------+-------+
| Variable_name | Value |
+---------------------+-------+
| max_delayed_threads | 20 |
+---------------------+-------+
1 row in set (0.00 sec)
mysql> show variables like 'max_heap_table_size';
+---------------------+----------+
| Variable_name | Value |
+---------------------+----------+
| max_heap_table_size | 16777216 |
+---------------------+----------+
1 row in set (0.00 sec)
mysql> show variables like 'max_tmp_tables';
+----------------+-------+
| Variable_name | Value |
+----------------+-------+
| max_tmp_tables | 32 |
+----------------+-------+
1 row in set (0.01 sec)
mysql> show variables like 'thread_cache_size';
+-------------------+-------+
| Variable_name | Value |
+-------------------+-------+
| thread_cache_size | 8 |
+-------------------+-------+
1 row in set (0.00 sec)
mysql> show variables like 'tmp_table_size';
+----------------+----------+
| Variable_name | Value |
+----------------+----------+
| tmp_table_size | 16777216 |
+----------------+----------+
1 row in set (0.00 sec)
mysql> show variables like 'wait_timeout';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| wait_timeout | 28800 |
+---------------+-------+
1 row in set (0.00 sec)
mysql> show variables like 'myisam_sort_buffer_size';
+-------------------------+---------+
| Variable_name | Value |
+-------------------------+---------+
| myisam_sort_buffer_size | 8388608 |
+-------------------------+---------+
1 row in set (0.00 sec)