Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b7f0d81

Browse files
committed
A lot of small improvements.
ec2.yml now reuses tasks for launching instances. We now take by default branch with read committed postgres_fdw. Running pgbench on single node. Mounting tmpfs and keeping pg there.
1 parent 3c80286 commit b7f0d81

File tree

10 files changed

+145
-23
lines changed

10 files changed

+145
-23
lines changed

devops/ec2.yml

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,9 @@
1212
region: eu-central-1
1313

1414
tasks:
15-
- name: start instances
16-
ec2:
17-
key_name: "{{ key_name }}"
18-
instance_type: "{{ instance_type }}"
19-
image: "{{ image }}"
20-
group: "{{ security_group }}"
21-
count: "{{ count }}"
22-
vpc_subnet_id: "{{ vpc_subnet_id }}"
23-
region: "{{ region }}"
24-
wait: yes
25-
assign_public_ip: yes
26-
vars:
27-
instance_type: t2.micro
28-
image: ami-1e339e71 # basic ubuntu backed by ebs
15+
16+
# image here is basic ubuntu backed by ebs
17+
- import_tasks: tasks/ec2.yml instance_type="t2.micro" image="ami-1e339e71"
2918
tags:
3019
- micro
3120

devops/inventory

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ ansible_python_interpreter=python3
1616

1717
# make -j
1818
makejobs=4
19-
pg_repo=git://git.postgresql.org/git/postgresql.git
20-
pg_version_tag=REL_10_STABLE
21-
pg_prefix="{{ansible_env.HOME}}/pg"
19+
# pg_repo=git://git.postgresql.org/git/postgresql.git
20+
# pg_version_tag=REL_10_STABLE
21+
pg_repo=https://github.com/arssher/postgresql
22+
pg_version_tag=postgres_fdw_read_committed
23+
# pg_prefix="{{ansible_env.HOME}}/pg"
24+
pg_prefix="/tmp/pg"
2225
pg_src="{{pg_prefix}}/src"
2326
cflags="-O2"
2427
pg_dst="{{pg_prefix}}/install"

devops/pgbench_prepare.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222

2323
- hosts: init_node
2424
vars:
25-
scale: 3
26-
nparts: 3
25+
scale: 10
26+
nparts: 10
2727
repfactor: 0
2828
environment:
2929
PATH: "{{ pg_dst }}/bin:{{ ansible_env.PATH }}"

devops/pgbench_run.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
### create pgbench_history everywhere, create pgbench tables on init node,
22
# shard them. TODO: drop sharded tables.
3-
# Controlling vars: tmstmp (true/false), tname, clients, seconds.
3+
# Controlling vars: tmstmp (true/false), tname, clients, t (true/false),
4+
# seconds, xacts
45

56

67
# set global var to use in all plays, oh my
@@ -22,6 +23,8 @@
2223
vars:
2324
clients: 1
2425
seconds: 5
26+
xacts: 100
27+
t: False
2528
environment:
2629
PATH: "{{ pg_dst }}/bin:{{ ansible_env.PATH }}"
2730

@@ -30,10 +33,21 @@
3033
command: >
3134
psql -p {{ pg_port }} -U {{ ansible_user }} -c "VACUUM;"
3235
33-
- name: run pgbench
36+
- name: run pgbench -T {{ seconds }}
3437
shell: >
35-
pgbench -p {{ pg_port }} --report-latencies --progress 1 --no-vacuum
38+
pgbench -p {{ pg_port }} --report-latencies --no-vacuum
3639
-c {{ clients }} -T {{ seconds }} 2>&1 > "{{ test_id }}.out"
40+
when: not ( t | bool )
41+
42+
- name: run pgbench -t {{ xacts }}
43+
shell: >
44+
pgbench -p {{ pg_port }} --report-latencies --no-vacuum
45+
-c {{ clients }} -t {{ xacts }} 2>&1 > "{{ test_id }}.out"
46+
when: t | bool
47+
48+
- name: clear log dir
49+
local_action: file path="res/{{ test_id }}/" state=absent
50+
run_once: true
3751

3852
- name: fetch pgbench exec times
3953
fetch:

devops/pgbench_single.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
### Init and run pgbench on random worker. Controlling vars as in
2+
# pgbench_prepare and pgbench_run, except for tname.
3+
---
4+
5+
- hosts: workers[0]
6+
environment:
7+
PATH: "{{ pg_dst }}/bin:{{ ansible_env.PATH }}"
8+
vars:
9+
scale: 10
10+
clients: 1
11+
tmstmp: True
12+
tname: pgbench
13+
14+
tasks:
15+
16+
- name: drop old pgbench tables with deps
17+
command: >
18+
psql -p {{ pg_port }} -c "
19+
drop table if exists pgbench_accounts cascade;
20+
drop table if exists pgbench_tellers cascade;
21+
drop table if exists pgbench_branches cascade;
22+
drop table if exists pgbench_tellers cascade;
23+
drop table if exists pgbench_accounts cascade;
24+
"
25+
- name: initialize pgbench, scale {{ scale }}
26+
command: >
27+
pgbench -p {{ pg_port }} -s {{ scale }} -i
28+
29+
- name: run pgbench -T {{ seconds }}
30+
shell: >
31+
pgbench -p {{ pg_port }} --report-latencies
32+
-c {{ clients }} -T {{ seconds }} 2>&1 > "pgbench.out"
33+
when: not ( t | bool )
34+
35+
- name: run pgbench -t {{ xacts }}
36+
shell: >
37+
pgbench -p {{ pg_port }} --report-latencies
38+
-c {{ clients }} -t {{ xacts }} 2>&1 > "pgbench.out"
39+
when: t | bool
40+
41+
- name: fetch pgbench exec time
42+
fetch:
43+
src: "pgbench.out"
44+
dest: res/pgbench_single.out
45+
flat: yes
46+
fail_on_missing: yes
47+
tags:
48+
- fetch

devops/postgresql.conf.common.example

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
TimeZone = 'Europe/Moscow'
2+
log_timezone = 'Europe/Moscow'
3+
4+
listen_addresses = '*'
5+
6+
log_min_messages = LOG
7+
client_min_messages = NOTICE
8+
log_replication_commands = on
9+
10+
max_replication_slots = 300
11+
max_wal_senders = 300
12+
max_logical_replication_workers = 300
13+
max_worker_processes = 300
14+
15+
# performance-related settings
16+
shared_buffers = {{ (ansible_memtotal_mb * 0.5) | int }}MB
17+
effective_cache_size = 4GB
18+
work_mem = 32MB
19+
max_connections = 1000
20+
# don't do checkpoints
21+
checkpoint_timeout = 60min
22+
max_wal_size = 100GB
23+
fsync = off
24+
autovacuum = off
25+
26+
shardman.shardlord_dbname = ubuntu
27+
shardman.poll_interval = 500 # long operations poll frequency in milliseconds

devops/provision.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
tags:
1616
- tz
1717

18+
- name: mount tmpfs as /tmp
19+
mount: >
20+
name=/tmp src='tmpfs' fstype=tmpfs
21+
opts='size={{ (ansible_memtotal_mb * 0.75) | int }}m' state=mounted
22+
become: yes
23+
tags:
24+
- tmpfs
25+
1826
- name: update apt cache (Debian)
1927
apt: update_cache=yes
2028
become: yes
@@ -60,6 +68,11 @@
6068
tags:
6169
- build_pg_fdw
6270

71+
- name: rm pg sources
72+
file: path="{{ pg_src }}" state=absent
73+
tags:
74+
- rm_pg_src
75+
6376
- name: clone pathman
6477
git: repo={{pathman_repo}}
6578
dest={{pathman_src}}
@@ -93,6 +106,11 @@
93106
tags:
94107
- build_shardman
95108

109+
- name: set PATH in .bashrc
110+
lineinfile: dest=~/.bashrc line="export PATH={{ pg_dst }}/bin:$PATH"
111+
tags:
112+
- set_path
113+
96114
- import_playbook: init.yml
97115
tags:
98116
- init

devops/readme.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ nodes': ansible-playbook -i inventory_ec2/ psql.yml --limit 'workers' -e "cmd='\
5757
Create, fill and shard pgbench tables:
5858
ansible-playbook -i inventory_ec2/ pgbench_prepare.yml -e "scale=10 nparts=3 repfactor=0"
5959
Run pgbench test:
60-
ansible-playbook -f 20 -i inventory_ec2/ pgbench_run.yml -e "tmstmp=false tname=test seconds=30"
60+
ansible-playbook -i inventory_ec2/ pgbench_run.yml -e "tmstmp=false tname=test seconds=30"
61+
Run pgbench on single worker (to estimate shardman overhead):
62+
ansible-playbook -i inventory_ec2/ pgbench_single.yml -e "scale=10 tmstmp=false tname=test t=false clients=8 seconds=15"
6163

6264
Gather logs to ./logs:
6365
ansible-playbook -i inventory_ec2/ logs.yml
@@ -71,6 +73,11 @@ Ubuntu images EC2 locator:
7173
https://cloud-images.ubuntu.com/locator/ec2/
7274
We need ami-4199282e.
7375

76+
Other hints:
77+
Currently pgbench exits on first error. postgres_fdw currently supports only
78+
repeatable read / serializable isolation levels which immediately leads to
79+
serialization errors, so you should use either patched postgres_fdw or pgbench.
80+
7481
Things that made me wonder during writing this:
7582
* Reusability of tasks. Playbooks, files with tasks, roles, includes, imports,
7683
old include API...probably working directly from Python would be easier? There

devops/send_config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
# Templates in the root of the project are copied automatically. You can append
33
# something to them by creating same-titled in this (devops/) directory, they
44
# are not tracked by git.
5+
# BTW, you can refer to ansible vars there.
6+
# The only guc we manage dynamically by default is shardlord_connstring, it
7+
# requires inventory knowledge
58

69
---
710
- hosts: shardlord

devops/tasks/ec2.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
3+
- name: start {{ count }} {{ instance_type }} instances
4+
ec2:
5+
key_name: "{{ key_name }}"
6+
instance_type: "{{ instance_type }}"
7+
image: "{{ image }}"
8+
group: "{{ security_group }}"
9+
count: "{{ count }}"
10+
vpc_subnet_id: "{{ vpc_subnet_id }}"
11+
region: "{{ region }}"
12+
wait: yes
13+
assign_public_ip: yes

0 commit comments

Comments
 (0)