Dgraph Latency Tests with Embargo

Results

I ran some latency tests using the embargo tool and dgraph increment. These were samples of 1000 queries and mutations against a 6-node Dgraph cluster (3 Zeros, 3 Alphas) on version v20.03.1.

Latency numbers are in one-direction, meaning that there’s an X-millisecond delay for outgoing requests between Dgraph instances.

Queries (Best-effort queries): These are best-effort queries give the current data from Alpha without needing to talk to Zero for the latest timestamp. These aren’t guaranteed to be linearizable reads.
Queries (Read-only queries): These queries are linearizable reads where Zero is contacted to update the latest timestamp if new writes came in. This is useful for read-only workloads with few writes.
Queries (Normal): These are queries as part of a regular transaction.
Mutations: These are mutations to update and commit data in Dgraph. This is part of a regular transaction.

See the docs for more info about best-effort and read-only queries.

90th Percentile Results

Queries (Best-Effort) Queries (Read-Only) Queries (Normal) Mutations
no latency 1.0ms 1.0ms 8.0ms 8.0ms
10ms latency 1.0ms 21.0ms 49.0ms 70.0ms
20ms latency 1.0ms 41.0ms 89.0ms 130.0ms
30ms latency 1.0ms 62.0ms 129.0ms 190.0ms
40ms latency 1.0ms 82.0ms 185.0ms 250.0ms
50ms latency 1.0ms 102.0ms 218.2ms 310.0ms

99th Percentile Results

Queries (Best-Effort) Queries (Read-Only) Queries (Normal) Mutations
no latency 1.0ms 2.0ms 10.0ms 10.0ms
10ms latency 1.0ms 22.0ms 69.0ms 72.0ms
20ms latency 1.0ms 42.0ms 126.0ms 131.0ms
30ms latency 1.0ms 62.0ms 185.01ms 192.0ms
40ms latency 1.0ms 82.0ms 193.01ms 253.0ms
50ms latency 1.0ms 102.0ms 255.02ms 313.0ms

Setup

Provision System

Install dgraph version

export DGRAPH_VERS=v20.03.1
curl -sSf https://get.dgraph.io | ACCEPT_LICENSE="y" VERSION="$DGRAPH_VERS" bash```

Setup Embargo

sudo su ubuntu; cd
pip install embargo
git clone https://github.com/dgraph-io/dgraph/
cd dgraph/contrib/embargo
export DGRAPH_VERS=v20.03.1
sed -i s/latest/$DGRAPH_VERS/ embargo.yml
echo '  slow: 0ms' >> embargo.yml
docker pull dgraph/dgraph:$DGRAPH_VERS

Run Tests

# 0ms..50ms (steps of 10ms)
export LATENCY=10ms  
sed -Ei "s/(slow: )(.*$)/\1$LATENCY/" embargo.yml
emabargo up
embargo slow --all
bash 1k.sh | tee -a samples/$LATENCY.txt
#!/usr/bin/env bash
# Script: 1k.sh
ADDR="localhost:9180"

for IDX in {1..1000}; do
  dgraph increment --alpha $ADDR | grep Latency
done

Compile Results

Created small ruby script to collect results.

#!/usr/bin/env ruby
# usage:
#   gem install descriptive_statistics
#   ./percentile_from_sample.rb samples/$LATENCY.txt
require 'descriptive_statistics'

filename = ARGV[0] || "sample.txt"
sample = File.open(filename, "r")
lines = sample.readlines.map(&:chomp)

# create empty samples structure
samples = { queries: [], mutations: [], servers: [],clients: [],   deltas: [] }

# populate samples
lines.each do |line|
   (query,mutation,server,client,delta) = line.split(/\sQ\s|\sM\s|\sS\s|\sC\s|\sD\s/)[1..5]
   samples[:queries] << query
   samples[:mutations] << mutation
   samples[:servers] << server
   samples[:clients] << client
   samples[:deltas] << delta
end

# craate percentiles from samples
percentiles = samples.keys.map { |type| [type, samples[type].percentile(90)] }.to_h

# output percentiles summary
percentiles.keys.each do |type|
  puts "#{type.capitalize} (90th percentile) #{percentiles[type]}ms"
end

# output in table format
puts "\nTable Format"
printf "|**90th Percentile** (XXms latency): |"
# index list in this order (keys may fall at random order)
%i[queries mutations servers clients deltas].each do |type|
  printf " %sms |", percentiles[type]
end
printf "\n"