Skip to content

Instantly share code, notes, and snippets.

@toshimaru
Last active September 1, 2025 00:41
Show Gist options
  • Save toshimaru/0a9e18d355d839a4d77343216660fbff to your computer and use it in GitHub Desktop.
Save toshimaru/0a9e18d355d839a4d77343216660fbff to your computer and use it in GitHub Desktop.
isucon14

Reference

Portal URL

https://isuride.xiv.isucon.net/

Servers

# Public IPv4 Private IPv4 SSH Command Example
1 57.182.67.171 192.168.0.11 ssh [email protected]
2 52.199.3.248 192.168.0.12 ssh [email protected]
3 18.181.63.225 192.168.0.13 ssh [email protected]

mysql command

$ mysql -h 192.168.0.13 -u isucon -p
use isuride;

Payment Microservice Mock

curl -H 'content-type: application/json' https://isuride.xiv.isucon.net/api/initialize -d '{"payment_server": "http://localhost:12345"}'

nginx.conf

$ cat /etc/nginx/sites-available/isuride.conf
Original
$ cat /etc/nginx/sites-available/isuride.conf
server {
  listen 80 default_server;
  server_name _;
  index index.html index.htm index.nginx-debian.html;
  root /var/www/html;
  location / {
    try_files $uri $uri/ =404;
  }
}

server {
  listen 443 ssl default_server;
  server_name _;
  index index.html index.htm index.nginx-debian.html;
  root /var/www/html;

  # bot避けのためのvhostで、この証明書は自己署名です
  ssl_certificate     /etc/nginx/tls/dummy.crt;
  ssl_certificate_key /etc/nginx/tls/dummy.key;
  ssl_protocols TLSv1.3;
  ssl_prefer_server_ciphers off;

  location / {
    try_files $uri $uri/ =404;
  }
}

server {
  listen 443 ssl;
  server_name xiv.isucon.net;
  server_name *.xiv.isucon.net;

  ssl_certificate     /etc/nginx/tls/_.xiv.isucon.net.crt;
  ssl_certificate_key /etc/nginx/tls/_.xiv.isucon.net.key;

  ssl_protocols TLSv1.3;
  ssl_prefer_server_ciphers off;

  client_max_body_size 10m;
  root /home/isucon/webapp/public/;
  location / {
    try_files $uri /index.html;
  }
  location /api/ {
    proxy_set_header Host $host;
    proxy_pass http://localhost:8080;
  }

  location /api/internal/ {
    # localhostからのみアクセスを許可
    allow 127.0.0.1;
    deny all;
    proxy_set_header Host $host;
    proxy_pass http://localhost:8080;
  }
}
file: /var/log/nginx/access.log
sort: sum
reverse: true
matching_groups:
- "^/api/chair/rides/[0-9A-Z]+/status$"
- "^/api/app/rides/[0-9A-Z]+/evaluation$"
- "^/assets/"
- "^/images/"
percentiles: [50, 95]
output: count,2xx,4xx,5xx,method,uri,min,max,avg,p50,p95,sum
#
# The MySQL database server configuration file.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
# Here is entries for some specific programs
# The following values assume you have at least 32M ram
[mysqld]
#
# * Basic Settings
#
user = mysql
# pid-file = /var/run/mysqld/mysqld.pid
# socket = /var/run/mysqld/mysqld.sock
# port = 3306
# datadir = /var/lib/mysql
# If MySQL is running as a replication slave, this should be
# changed. Ref https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_tmpdir
# tmpdir = /tmp
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address = 127.0.0.1
#mysqlx-bind-address = 127.0.0.1
bind-address = 0.0.0.0
mysqlx-bind-address = 0.0.0.0
#
# * Fine Tuning
#
#key_buffer_size = 16M
key_buffer_size = 128M
# max_allowed_packet = 64M
# thread_stack = 256K
# thread_cache_size = -1
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover-options = BACKUP
# max_connections = 151
max_connections = 1000
# table_open_cache = 4000
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
#
# Log all queries
# Be aware that this log type is a performance killer.
# general_log_file = /var/log/mysql/query.log
# general_log = 1
#
# Error log - should be very few entries.
#
log_error = /var/log/mysql/error.log
#
# Here you can see queries with especially long duration
# slow_query_log = 1
# slow_query_log_file = /var/log/mysql/mysql-slow.log
# long_query_time = 2
# log-queries-not-using-indexes
#######
#slow_query_log = 1
#slow_query_log_file = /var/log/mysql/slow-query.log
#long_query_time = 2
#log_queries_not_using_indexes = 1
#######
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
# other settings you may need to change.
# server-id = 1
# log_bin = /var/log/mysql/mysql-bin.log
# binlog_expire_logs_seconds = 2592000
max_binlog_size = 100M
# binlog_do_db = include_database_name
# binlog_ignore_db = include_database_name
#
# Added
disable_log_bin
wait_timeout = 300
innodb_buffer_pool_size=3G
server {
listen 80 default_server;
server_name _;
index index.html index.htm index.nginx-debian.html;
root /var/www/html;
location / {
try_files $uri $uri/ =404;
}
}
server {
listen 443 ssl default_server;
server_name _;
index index.html index.htm index.nginx-debian.html;
root /var/www/html;
# bot避けのためのvhostで、この証明書は自己署名です
ssl_certificate /etc/nginx/tls/dummy.crt;
ssl_certificate_key /etc/nginx/tls/dummy.key;
ssl_protocols TLSv1.3;
ssl_prefer_server_ciphers off;
location / {
try_files $uri $uri/ =404;
}
}
upstream backend_servers {
#server 192.168.0.11:8080; # server1
server 192.168.0.12:8080; # server2
#server 192.168.0.13:8080; # server3
}
server {
listen 443 ssl;
server_name xiv.isucon.net;
server_name *.xiv.isucon.net;
ssl_certificate /etc/nginx/tls/_.xiv.isucon.net.crt;
ssl_certificate_key /etc/nginx/tls/_.xiv.isucon.net.key;
ssl_protocols TLSv1.3;
ssl_prefer_server_ciphers off;
client_max_body_size 10m;
root /home/isucon/webapp/public/;
location / {
try_files $uri /index.html;
}
location /api/ {
proxy_set_header Host $host;
proxy_pass http://localhost:8080;
#proxy_pass http://backend_servers; # ロードバランサーを使用
}
location /api/owner/ {
proxy_set_header Host $host;
proxy_pass http://backend_servers;
}
location /api/chair/coordinate {
proxy_set_header Host $host;
proxy_pass http://backend_servers;
}
location /api/app/rides {
proxy_set_header Host $host;
proxy_pass http://backend_servers;
}
location /api/chair/rides/ {
proxy_set_header Host $host;
proxy_pass http://backend_servers;
}
location /api/internal/ {
# localhostからのみアクセスを許可
allow 127.0.0.1;
deny all;
proxy_set_header Host $host;
proxy_pass http://localhost:8080;
}
}
select
SCHEMA_NAME,
-- DIGEST,
DIGEST_TEXT,
COUNT_STAR,
round(SUM_TIMER_WAIT / pow(1000,4), 3) as SUM_TIMER_WAIT_SEC,
round(MIN_TIMER_WAIT / pow(1000,4), 3) as MIN_TIMER_WAIT_SEC,
round(AVG_TIMER_WAIT / pow(1000,4), 3) as AVG_TIMER_WAIT_SEC,
round(MAX_TIMER_WAIT / pow(1000,4), 3) as MAX_TIMER_WAIT_SEC,
round(SUM_LOCK_TIME / pow(1000,4), 3) as SUM_LOCK_TIME_SEC,
round(QUANTILE_95 / pow(1000,4), 3) as P95,
round(QUANTILE_99 / pow(1000,4), 3) as P99,
round(QUANTILE_999 / pow(1000,4), 3) as P999,
SUM_ERRORS,
SUM_WARNINGS,
SUM_ROWS_AFFECTED,
SUM_ROWS_SENT,
SUM_ROWS_EXAMINED,
SUM_CREATED_TMP_DISK_TABLES,
SUM_CREATED_TMP_TABLES,
SUM_SELECT_FULL_JOIN,
SUM_SELECT_FULL_RANGE_JOIN,
SUM_SELECT_RANGE,
SUM_SELECT_RANGE_CHECK,
SUM_SELECT_SCAN,
SUM_SORT_MERGE_PASSES,
SUM_SORT_RANGE,
SUM_SORT_ROWS,
SUM_SORT_SCAN,
SUM_NO_INDEX_USED,
SUM_NO_GOOD_INDEX_USED,
-- round(SUM_CPU_TIME / pow(1000,4), 3) as SUM_CPU_TIME_SEC,
round(MAX_CONTROLLED_MEMORY / pow(1024,2), 3) as MAX_CONTROLLED_MEMORY_MB,
round(MAX_TOTAL_MEMORY / pow(1024,2), 3) as MAX_TOTAL_MEMORY_MB,
-- COUNT_SECONDARY,
-- FIRST_SEEN,
-- LAST_SEEN,
QUERY_SAMPLE_TEXT,
-- QUERY_SAMPLE_SEEN,
round(QUERY_SAMPLE_TIMER_WAIT / pow(1000,4), 3) as QUERY_SAMPLE_TIMER_WAIT_SEC
from
performance_schema.events_statements_summary_by_digest
where
`SCHEMA_NAME` != 'performance_schema'
AND `SCHEMA_NAME` IS NOT NULL
order by
SUM_TIMER_WAIT desc
limit
20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment