saza-ku / private-isu-2023-public

0 stars 0 forks source link

10181219 #7

Open saza-ku opened 1 year ago

saza-ku commented 1 year ago

isucon1

alp

+-------+--------+--------------------+-------+-------+---------+-------+-------+
| COUNT | METHOD |        URI         |  MIN  |  MAX  |   SUM   |  AVG  |  P99  |
+-------+--------+--------------------+-------+-------+---------+-------+-------+
| 785   | GET    | /                  | 0.056 | 0.612 | 247.252 | 0.315 | 0.540 |
| 13993 | GET    | /image/.+          | 0.000 | 0.132 | 131.116 | 0.009 | 0.056 |
| 180   | GET    | /posts             | 0.068 | 0.708 | 80.808  | 0.449 | 0.668 |
| 182   | GET    | /@.+               | 0.048 | 0.640 | 64.348  | 0.354 | 0.596 |
| 1195  | GET    | /posts/.+          | 0.004 | 0.168 | 55.524  | 0.046 | 0.140 |
| 575   | POST   | /login             | 0.004 | 0.148 | 22.324  | 0.039 | 0.100 |
| 138   | POST   | /                  | 0.000 | 0.244 | 6.672   | 0.048 | 0.204 |
| 81    | POST   | /register          | 0.016 | 0.124 | 4.828   | 0.060 | 0.124 |
| 1571  | GET    | /favicon.ico       | 0.000 | 0.060 | 3.052   | 0.002 | 0.020 |
| 1571  | GET    | /js/timeago.min.js | 0.000 | 0.068 | 2.608   | 0.002 | 0.020 |
| 1571  | GET    | /js/main.js        | 0.000 | 0.044 | 2.276   | 0.001 | 0.016 |
| 1571  | GET    | /css/style.css     | 0.000 | 0.040 | 2.020   | 0.001 | 0.016 |
| 74    | POST   | /comment           | 0.004 | 0.152 | 1.784   | 0.024 | 0.152 |
| 81    | GET    | /admin/banned      | 0.004 | 0.052 | 0.600   | 0.007 | 0.052 |
| 188   | GET    | /login             | 0.000 | 0.044 | 0.584   | 0.003 | 0.032 |
| 94    | GET    | /logout            | 0.004 | 0.024 | 0.340   | 0.004 | 0.024 |
+-------+--------+--------------------+-------+-------+---------+-------+-------+

slow query

Count: 785  Time=0.07s (53s)  Lock=0.00s (0s)  Rows=10033.9 (7876576), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at` FROM `posts` ORDER BY `created_at` DESC

Count: 246073  Time=0.00s (18s)  Lock=0.00s (0s)  Rows=7.8 (1918425), isuconp[isuconp]@localhost
  #

Count: 15188  Time=0.00s (14s)  Lock=0.00s (0s)  Rows=1.0 (15188), isuconp[isuconp]@localhost
  SELECT * FROM `posts` WHERE `id` = N

Count: 59236  Time=0.00s (14s)  Lock=0.00s (0s)  Rows=1.0 (59236), isuconp[isuconp]@localhost
  SELECT * FROM `users` WHERE `id` = N

Count: 180  Time=0.08s (13s)  Lock=0.00s (0s)  Rows=9894.9 (1781090), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at` FROM `posts` WHERE `created_at` <= 'S' ORDER BY `created_at` DESC

Count: 182  Time=0.07s (13s)  Lock=0.00s (0s)  Rows=1.0 (182), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS count FROM `comments` WHERE `user_id` = N

Count: 22602  Time=0.00s (6s)  Lock=0.00s (0s)  Rows=1.0 (22602), isuconp[isuconp]@localhost
  SELECT COUNT(*) AS `count` FROM `comments` WHERE `post_id` = N

Count: 21407  Time=0.00s (6s)  Lock=0.00s (0s)  Rows=1.1 (24482), isuconp[isuconp]@localhost
  SELECT * FROM `comments` WHERE `post_id` = N ORDER BY `created_at` DESC LIMIT N

Count: 182  Time=0.02s (4s)  Lock=0.00s (0s)  Rows=10.0 (1813), isuconp[isuconp]@localhost
  SELECT `id`, `user_id`, `body`, `mime`, `created_at` FROM `posts` WHERE `user_id` = N ORDER BY `created_at` DESC

Count: 69  Time=0.06s (4s)  Lock=0.00s (0s)  Rows=0.0 (0), isuconp[isuconp]@localhost
  INSERT INTO `posts` (`user_id`, `mime`, `imgdata`, `body`) VALUES (N,'S','S','S')

explain

Reading from STDIN ...

# 24.9s user time, 180ms system time, 51.43M rss, 65.20M vsz
# Current date: Wed Oct 18 00:21:40 2023
# Hostname: private-isu
# Files: STDIN
# Overall: 374.65k total, 27 unique, 4.57k QPS, 1.87x concurrency ________
# Time range: 2023-10-17T15:19:53 to 2023-10-17T15:21:15
# Attribute          total     min     max     avg     95%  stddev  median
# ============     ======= ======= ======= ======= ======= ======= =======
# Exec time           154s     1us   205ms   409us   657us     4ms    44us
# Lock time          309ms       0    10ms       0     1us    27us       0
# Rows sent          9.34M       0   9.83k   26.14    0.99  494.67       0
# Rows examine      37.78M       0  97.73k  105.74    2.90   2.34k       0
# Query size        53.66M      17   1.26M  150.18   80.10  10.07k   31.70

# Profile
# Rank Query ID                     Response time Calls  R/Call V/M   Item
# ==== ============================ ============= ====== ====== ===== ====
#    1 0x4858CF4D8CAA743E839C127... 53.2700 34.7%    785 0.0679  0.02 SELECT posts
#    2 0xDA556F9115773A1A99AA016... 16.9532 11.0% 121597 0.0001  0.00 ADMIN PREPARE
#    3 0x19759A5557089FD5B718D44... 14.8948  9.7%  15188 0.0010  0.00 SELECT posts
#    4 0x396201721CD58410E070DA9... 14.3426  9.3%  59236 0.0002  0.00 SELECT users
# MISC 0xMISC                       54.0498 35.2% 177843 0.0003   0.0 <23 ITEMS>

# Query 1: 12.87 QPS, 0.87x concurrency, ID 0x4858CF4D8CAA743E839C127C71B69E75 at byte 73375750
# This item is included in the report because it matches --limit.
# Scores: V/M = 0.02
# Time range: 2023-10-17T15:19:53 to 2023-10-17T15:20:54
# Attribute    pct   total     min     max     avg     95%  stddev  median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count          0     785
# Exec time     34     53s    17ms   205ms    68ms   134ms    34ms    59ms
# Lock time      0     2ms       0   679us     2us     1us    23us     1us
# Rows sent     80   7.51M   9.77k   9.83k   9.80k   9.80k   34.50   9.80k
# Rows examine  39  15.02M  19.53k  19.67k  19.60k  19.40k       0  19.40k
# Query size     0  70.53k      92      92      92      92       0      92
# String:
# Hosts        localhost
# Users        isuconp
# Query_time distribution
#   1us
#  10us
# 100us
#   1ms
#  10ms  ################################################################
# 100ms  ################
#    1s
#  10s+
# Tables
#    SHOW TABLE STATUS LIKE 'posts'\G
#    SHOW CREATE TABLE `posts`\G
# EXPLAIN /*!50100 PARTITIONS*/
SELECT `id`, `user_id`, `body`, `mime`, `created_at` FROM `posts` ORDER BY `created_at` DESC\G
# *************************** 1. row ***************************
#            id: 1
#   select_type: SIMPLE
#         table: posts
#    partitions: NULL
#          type: ALL
# possible_keys: NULL
#           key: NULL
#       key_len: NULL
#           ref: NULL
#          rows: 9477
#      filtered: 100.00
#         Extra: Using filesort

# Query 2: 1.96k QPS, 0.27x concurrency, ID 0xDA556F9115773A1A99AA0165670CE848 at byte 9585532
# This item is included in the report because it matches --limit.
# Scores: V/M = 0.00
# Time range: 2023-10-17T15:19:53 to 2023-10-17T15:20:55
# Attribute    pct   total     min     max     avg     95%  stddev  median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count         32  121597
# Exec time     11     17s    21us   105ms   139us   467us   626us    44us
# Lock time      0       0       0       0       0       0       0       0
# Rows sent      0       0       0       0       0       0       0       0
# Rows examine   0       0       0       0       0       0       0       0
# Query size     6   3.48M      30      30      30      30       0      30
# String:
# Hosts        localhost
# Users        isuconp
# Query_time distribution
#   1us
#  10us  ################################################################
# 100us  #########
#   1ms  #
#  10ms  #
# 100ms  #
#    1s
#  10s+
administrator command: Prepare\G

# Query 3: 244.97 QPS, 0.24x concurrency, ID 0x19759A5557089FD5B718D440CBBB5C55 at byte 24949925
# This item is included in the report because it matches --limit.
# Scores: V/M = 0.00
# Time range: 2023-10-17T15:19:53 to 2023-10-17T15:20:55
# Attribute    pct   total     min     max     avg     95%  stddev  median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count          4   15188
# Exec time      9     15s    92us    54ms   980us     4ms     2ms   273us
# Lock time     12    40ms       0     5ms     2us     1us    47us     1us
# Rows sent      0  14.83k       1       1       1       1       0       1
# Rows examine   0  14.83k       1       1       1       1       0       1
# Query size     1 585.00k      37      40   39.44   38.53    0.26   38.53
# String:
# Hosts        localhost
# Users        isuconp
# Query_time distribution
#   1us
#  10us  #
# 100us  ################################################################
#   1ms  ###############
#  10ms  #
# 100ms
#    1s
#  10s+
# Tables
#    SHOW TABLE STATUS LIKE 'posts'\G
#    SHOW CREATE TABLE `posts`\G
# EXPLAIN 
SELECT * FROM `posts` WHERE `id` = 10212\G
# *************************** 1. row ***************************
#            id: 1
#   select_type: SIMPLE
#         table: posts
#    partitions: NULL
#          type: const
# possible_keys: PRIMARY
#           key: PRIMARY
#       key_len: 4
#           ref: const
#          rows: 1
#      filtered: 100.00
#         Extra: NULL

# Query 4: 955.42 QPS, 0.23x concurrency, ID 0x396201721CD58410E070DA9421CA8C8D at byte 26414559
# This item is included in the report because it matches --limit.
# Scores: V/M = 0.00
# Time range: 2023-10-17T15:19:53 to 2023-10-17T15:20:55
# Attribute    pct   total     min     max     avg     95%  stddev  median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count         15   59236
# Exec time      9     14s    38us    37ms   242us   925us   734us    69us
# Lock time     44   138ms       0    10ms     2us     1us    49us     1us
# Rows sent      0  57.85k       1       1       1       1       0       1
# Rows examine   0  57.85k       1       1       1       1       0       1
# Query size     3   2.14M      36      39   37.90   36.69    0.17   36.69
# String:
# Hosts        localhost
# Users        isuconp
# Query_time distribution
#   1us
#  10us  ################################################################
# 100us  ####################
#   1ms  ####
#  10ms  #
# 100ms
#    1s
#  10s+
# Tables
#    SHOW TABLE STATUS LIKE 'users'\G
#    SHOW CREATE TABLE `users`\G
# EXPLAIN 
SELECT * FROM `users` WHERE `id` = 227\G
# *************************** 1. row ***************************
#            id: 1
#   select_type: SIMPLE
#         table: users
#    partitions: NULL
#          type: const
# possible_keys: PRIMARY
#           key: PRIMARY
#       key_len: 4
#           ref: const
#          rows: 1
#      filtered: 100.00
#         Extra: NULL

netdata

http://localhost:19991/#menu_apps_submenu_cpu;after=1697555993053;before=1697556069394