ISUCON10 Final (XSUCON Portal)

Directories

Prerequisite

TLS certificate

You need a wildcard TLS certificate or a TLS certificate for at least 2 subjects, for the following purposes:

Obtain and place it at secrets/cert.pem and secrets/key.pem.

Build a frontend

cd webapp/frontend
yarn
yarn build

Running a benchmarker locally

cd benchmarker
make
./bin/benchmarker \
    -exit-status \
    -target app.t.isucon.dev:3000 \
    -host-advertise local.t.isucon.dev \
    -tls-cert ../secrets/tls-cert.pem \
    -tls-key ../secrets/tls-key.pem

Running a machine image

Embed ssh public key (optional)

Edit packer/files/itamae/cookbooks/isucon-user/default.rb to embed ssh public keys in advance. You don't need this when building a EC2 AMI.

Build

cd packer/

# Build Amazon EC2 AMI
make build-full-ec2
# Build QEMU qcow2
make build-full-qemu

Run

Boot built image on QEMU(Virtualbox) or EC2.

1. Log in

2. Add server names to /etc/hosts

You need to add names to /etc/hosts for connecting app from benchmarker & connecting app to benchmarker WebPush service. Assume you have a *.t.isucon.dev TLS certificate, you can add the followings:

app.t.isucon.dev   127.0.0.1
bench.t.isucon.dev 127.0.0.1

3. Adjust CPU/RAM assignment

sudo vim /etc/systemd/system/contestant.slice
sudo vim /etc/systemd/system/benchmarker.slice

sudo systemctl daemon-reload
sudo systemctl restart contestant.slice benchmarker.slice

4. Start task application

Follow the task description. By default, all implementations are disabled, so you need to enable them and start:

sudo systemctl enable --now xsuportal-api-ruby.service xsuportal-web-ruby.service

5. Run a benchmarker

As a isucon user, run:

sudo systemd-run \
  --working-directory=/home/isucon/benchmarker \
  --pipe \
  --wait \
  --collect \
  --uid=$(id -u)\
  --gid=$(id -g) \
  --slice=benchmarker.slice \
  --service-type=oneshot \
  -p AmbientCapabilities=CAP_NET_BIND_SERVICE \
  -p CapabilityBoundingSet=CAP_NET_BIND_SERVICE \
  -p LimitNOFILE=2000000 \
  -p TimeoutStartSec=110s \
    ~isucon/benchmarker/bin/benchmarker \
    -exit-status \
    -tls \
    -target app.t.isucon.dev:443 \
    -host-advertise bench.t.isucon.dev \
    -push-service-port 1001 \
    -tls-cert /etc/ssl/private/tls-cert.pem \
    -tls-key /etc/ssl/private/tls-key.pem \

(Adjust -target and -host-advertise as your domain names)

Expected machine specs

License

MIT License unless otherwise specified