Skip to content

Instantly share code, notes, and snippets.

@repeatedly
Last active May 31, 2020 03:45
Show Gist options
  • Save repeatedly/672ac73abf7cbcb629aaec791838cf6d to your computer and use it in GitHub Desktop.
Save repeatedly/672ac73abf7cbcb629aaec791838cf6d to your computer and use it in GitHub Desktop.
Fluentd: HTTP input simple benchmark
<source>
@type http
port 8888
</source>
<match test.**>
@type flowcounter_simple
</match>
require 'net/http'
require 'json'
require 'msgpack'
r = {"_id" => "5671172e7ba230441460f011","index" => 0,"guid" => "3d18838a-ae85-4986-83c7-e4a4acdd7f01","isActive" => false,"balance" => 3.92,"picture" => "http://placehold.it/32x32","age" => 40,"eyeColor" => "green","company" => "MEDMEX","email" => "hardin.sargent@medmex.org","phone" => "+1 (865) 468-2885","address" => "302 Buffalo Avenue, Bend, Louisiana, 635","latitude" => 89.385551,"longitude" => 75.132185,"greeting" => "Hello, Hardin! You have 5 unread messages."}
case 2 # choose 0, 1 or 2
when 0
record = {'json' => r.to_json}
when 1
record = {'msgpack' => r.to_msgpack}
when 2
arr = []
10.times {
arr << r
}
record = {'msgpack' => arr.to_msgpack}
end
http = Net::HTTP.new("127.0.0.1", 8888)
req = Net::HTTP::Post.new('/test.http', {})
req['Connection'] = 'Keep-Alive'
req.set_form_data(record)
http.start
i = 0
loop {
http.request(req)
i += 1
if i % 1000 == 0
puts "posted #{i}"
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment