{"pass":true,"score":4193,"success":4037,"fail":0,"messages":[]}
$ mysql -u isuconp -pisuconp isuconp -e "alter table comments add index comments_idx_1 (post_id, created_at DESC);"
{"pass":true,"score":34720,"success":32646,"fail":0,"messages":[]}
location ~ .*\.(ico|css|js|img) {
expires 1d;
add_header Cache-Control public;
}
{"pass":true,"score":34846,"success":32802,"fail":0,"messages":[]}
- https://github.com/melanmeg/private-isu-challenge/commit/9665894c45f6c09bdfaf2efbc1dd09de8acbf144
- https://github.com/melanmeg/private-isu-challenge/commit/d7053047c2a1fac6ab9f1d6888ee28125f2eca4e
{"pass":true,"score":54217,"success":51773,"fail":0,"messages":[]}
{"pass":true,"score":72393,"success":69147,"fail":0,"messages":[]}
mysql> EXPLAIN
-> SELECT p.id, p.user_id, p.body, p.mime, p.created_at
-> FROM posts AS p
-> JOIN users AS u ON (p.user_id = u.id)
-> WHERE u.del_flg = 0
-> ORDER BY p.created_at DESC
-> LIMIT 20;
+----+-------------+-------+------------+--------+---------------+---------+---------+-------------------+------+----------+----------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+-------+------------+--------+---------------+---------+---------+-------------------+------+----------+----------------+
| 1 | SIMPLE | p | NULL | ALL | NULL | NULL | NULL | NULL | 9791 | 100.00 | Using filesort |
| 1 | SIMPLE | u | NULL | eq_ref | PRIMARY | PRIMARY | 4 | isuconp.p.user_id | 1 | 10.00 | Using where |
+----+-------------+-------+------------+--------+---------------+---------+---------+-------------------+------+----------+----------------+
2 rows in set, 1 warning (0.00 sec)
$ mysql -u isuconp -pisuconp isuconp -e "alter table posts add index posts_idx_1 (created_at DESC);"
{"pass":true,"score":82680,"success":78917,"fail":0,"messages":[]}
mysql> EXPLAIN SELECT p.id, p.user_id, p.body, p.mime, p.created_at FROM posts AS p JOIN users AS u ON (p.user_id = u.id) WHERE u.del_flg = 0 ORDER BY p.created_at DESC LIMIT 20;
+----+-------------+-------+------------+--------+---------------+---------------------+---------+-------------------+------+----------+-------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+-------+------------+--------+---------------+---------------------+---------+-------------------+------+----------+-------------+
| 1 | SIMPLE | p | NULL | index | NULL | idx_created_at_desc | 4 | NULL | 199 | 100.00 | NULL |
| 1 | SIMPLE | u | NULL | eq_ref | PRIMARY | PRIMARY | 4 | isuconp.p.user_id | 1 | 10.00 | Using where |
+----+-------------+-------+------------+--------+---------------+---------------------+---------+-------------------+------+----------+-------------+
2 rows in set, 1 warning (0.00 sec)
mysql> EXPLAIN SELECT COUNT(*) AS `count` FROM `comments` WHERE `user_id` = 382 \G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: comments
partitions: NULL
type: ALL
possible_keys: NULL
key: NULL
key_len: NULL
ref: NULL
rows: 99590
filtered: 10.00
Extra: Using where
1 row in set, 1 warning (0.00 sec)
$ mysql -u isuconp -pisuconp isuconp -e "alter table comments add index comments_idx_2 (user_id);"
mysql> EXPLAIN SELECT COUNT(*) AS `count` FROM `comments` WHERE `user_id` = 382 \G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: comments
partitions: NULL
type: ref
possible_keys: comments_idx_2
key: comments_idx_2
key_len: 4
ref: const
rows: 102
filtered: 100.00
Extra: Using index
1 row in set, 1 warning (0.00 sec)
{"pass":true,"score":86961,"success":83035,"fail":0,"messages":[]}
{"pass":true,"score":171163,"success":164317,"fail":0,"messages":[]}
{"pass":true,"score":179618,"success":172416,"fail":0,"messages":[]}
{"pass":true,"score":207649,"success":200667,"fail":0,"messages":[]}
{"pass":true,"score":437170,"success":424398,"fail":0,"messages":[]}
# 構成
isu1: nginx, app
isu2: app, memcached
isu3: mysql
{"pass":true,"score":442852,"success":429990,"fail":0,"messages":[]}
pproteinとphpmyadminの用意
# SSH後に実行
$ cd ~ && \
git clone https://github.com/melanmeg/private-isu-challenge.git && \
mv private_isu private_isu.bk && \
mv private-isu-challenge private_isu && \
ssh-keygen -t ed25519 -C "" -f ~/.ssh/id_ed25519 -N "" && \
sudo apt update -y
# private-isuでGOROOT空だったので、そのような場合にGoをインストールする
$ sudo rm -rf /usr/local/go
$ TAR_FILENAME=$(curl 'https://go.dev/dl/?mode=json' | jq -r '.[0].files[] | select(.os == "linux" and .arch == "amd64" and .kind == "archive") | .filename')
$ URL="https://go.dev/dl/$TAR_FILENAME"
$ curl -fsSL "$URL" -o /tmp/go.tar.gz && \
sudo tar -C /usr/local -xzf /tmp/go.tar.gz && \
rm -f /tmp/go.tar.gz
$ cat <<EOF >> ~/.bashrc
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=/usr/local/go/bin:$PATH
EOF