Skip to content

Instantly share code, notes, and snippets.

@Paxa
Last active May 12, 2017 09:34
Show Gist options
  • Save Paxa/bc657a4aa666872bed4c88775cec45de to your computer and use it in GitHub Desktop.
Save Paxa/bc657a4aa666872bed4c88775cec45de to your computer and use it in GitHub Desktop.
Persistent HTTPS vs not persistent
Run from cloud server in Jakarta, sending requests to cloud server in Singapore
Warming up --------------------------------------
excon 1.000 i/100ms
net-http2 1.000 i/100ms
net-http 1.000 i/100ms
net-http2 persistent 6.000 i/100ms
excon persistent 5.000 i/100ms
http persistent 6.000 i/100ms
Calculating -------------------------------------
excon 9.433 (± 0.0%) i/s - 48.000 in 5.094523s
net-http2 5.686 (± 0.0%) i/s - 29.000 in 5.100590s
net-http 13.184 (± 7.6%) i/s - 64.000 in 5.031864s
net-http2 persistent 62.187 (± 1.6%) i/s - 312.000 in 5.018698s
excon persistent 61.577 (±11.4%) i/s - 300.000 in 5.009494s
http persistent 65.735 (± 6.1%) i/s - 330.000 in 5.049852s
Comparison:
http persistent: 65.7 i/s
net-http2 persistent: 62.2 i/s - same-ish: difference falls within error
excon persistent: 61.6 i/s - same-ish: difference falls within error
net-http: 13.2 i/s - 4.99x slower
excon: 9.4 i/s - 6.97x slower
net-http2: 5.7 i/s - 11.56x slower
Run from local computer in Bali, sending requests to cloud server in Singapore
Warming up --------------------------------------
excon 1.000 i/100ms
net-http2 1.000 i/100ms
net-http 1.000 i/100ms
net-http2 persistent 2.000 i/100ms
excon persistent 2.000 i/100ms
http persistent 2.000 i/100ms
Calculating -------------------------------------
excon 4.573 (±21.9%) i/s - 20.000 in 5.056956s
net-http2 6.072 (±16.5%) i/s - 28.000 in 5.093250s
net-http 6.350 (±15.7%) i/s - 32.000 in 5.111458s
net-http2 persistent 28.033 (± 0.0%) i/s - 142.000 in 5.066763s
excon persistent 27.083 (±11.1%) i/s - 130.000 in 5.002292s
http persistent 26.914 (±18.6%) i/s - 120.000 in 5.061494s
Comparison:
net-http2 persistent: 28.0 i/s
excon persistent: 27.1 i/s - same-ish: difference falls within error
http persistent: 26.9 i/s - same-ish: difference falls within error
net-http: 6.3 i/s - 4.41x slower
net-http2: 6.1 i/s - 4.62x slower
excon: 4.6 i/s - 6.13x slower
Run from cloud server in US, sending requests to cloud server in Singapore
Warming up --------------------------------------
excon 1.000 i/100ms
net-http2 1.000 i/100ms
net-http 1.000 i/100ms
net-http2 persistent 1.000 i/100ms
excon persistent 1.000 i/100ms
http persistent 1.000 i/100ms
Calculating -------------------------------------
excon 0.932 (± 0.0%) i/s - 5.000 in 5.374344s
net-http2 0.887 (± 0.0%) i/s - 5.000 in 5.642097s
net-http 0.942 (± 0.0%) i/s - 5.000 in 5.316983s
net-http2 persistent 3.625 (± 0.0%) i/s - 19.000 in 5.241966s
excon persistent 3.463 (±28.9%) i/s - 16.000 in 5.249240s
http persistent 3.820 (±26.2%) i/s - 18.000 in 5.057508s
Comparison:
http persistent: 3.8 i/s
net-http2 persistent: 3.6 i/s - same-ish: difference falls within error
excon persistent: 3.5 i/s - same-ish: difference falls within error
net-http: 0.9 i/s - 4.06x slower
excon: 0.9 i/s - 4.10x slower
net-http2: 0.9 i/s - 4.31x slower
require 'excon'
require 'net-http2'
require 'net/http'
require 'benchmark/ips'
TEST_HOST = 'https://test-server.info'
http2_per = NetHttp2::Client.new(TEST_HOST)
excon_per = Excon.new(TEST_HOST, persistent: true)
http_uri = URI(TEST_HOST)
http_per = Net::HTTP.start(http_uri.host, http_uri.port, use_ssl: true)
Benchmark.ips do |x|
x.report("excon") {
Excon.get(TEST_HOST)
}
x.report("net-http2") do
client = NetHttp2::Client.new(TEST_HOST)
response = client.call(:get, '/')
client.close
end
x.report("net-http") do
uri = URI(TEST_HOST)
Net::HTTP.get(uri) # => String
end
x.report("net-http2 persistent") do
response = http2_per.call(:get, '/')
end
x.report("excon persistent") do
response = excon_per.get
end
x.report("http persistent") do
request = Net::HTTP::Get.new(http_uri)
response = http_per.request(request)
end
x.compare!
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment